Skip to content

Instantly share code, notes, and snippets.

@maliciousgroup
Created April 6, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maliciousgroup/71f6362eb81a0b7e6b34990dc7a2f52f to your computer and use it in GitHub Desktop.
Save maliciousgroup/71f6362eb81a0b7e6b34990dc7a2f52f to your computer and use it in GitHub Desktop.
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