-
-
Save maliciousgroup/71f6362eb81a0b7e6b34990dc7a2f52f to your computer and use it in GitHub Desktop.
Tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from prettytable import PrettyTable | |
def create_table(field_names: list, field_values: list) -> str: | |
t = PrettyTable() | |
t.border = False | |
t.padding_width = 2 | |
t.field_names = field_names | |
sep = [] | |
for _value in field_names: | |
sep += ['-' * len(_value)] | |
t.add_row(sep) | |
for _value in field_values: | |
t.add_row(_value) | |
t.align = 'l' | |
return "{}".format(t.get_string()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment