it_is_a_literature it_is_a_literature - 5 months ago 35
Python Question

Can i write the output format created by prettytable into a file?

can represent tabular data in visually appealing formatted tables, and print these tables to the terminal.

How do I save a table as a text file?


According to the tutorial section on ASCII tables, you can get the table output as a string:

table = ... # code for creating table goes here
table_txt = table.get_string()
with open('output.txt','w') as file: