def lol_to_table(lol, format=None, headers=None):
"""
Args:
lol (list): list of lists
format (str): text
headers (list): list of fields to be used as headers
Return:
obj - prettytable object
"""
table = PrettyTable(field_names=headers)
for ds_row in lol:
table.add_row([f for f in ds_row])
if format == 'text':
table.set_style(PLAIN_COLUMNS)
if format == 'word':
table.set_style(MSWORD_FRIENDLY)
table = table.get_string()
return table
评论列表
文章目录