spock
6/11/2017 - 11:12 AM

Print pretty table like the one below:

Print pretty table like the one below:

from prettytable import PrettyTable

table = PrettyTable(['food','price'])
table.add_row(['ham','$2'])
table.add_row(['eggs','$1'])
table.add_row(['spam','$4'])
print(table)

"""
>>>

+------+-------+
| food | price |
+------+-------+
| ham  |   $2  |
| eggs |   $1  |
| spam |   $4  |
+------+-------+
"""