Skip to content

Instantly share code, notes, and snippets.

@maliciousgroup

maliciousgroup/tables.py Secret

Created Apr 6, 2021
Embed
What would you like to do?
Tables
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