it_is_a_literature it_is_a_literature - 1 year ago 91
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?

Answer Source

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:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download