Kind of confusing for other people to read, though, so don't do this unless you have a Some of your table in one way and some of it in the other. If you really want to, you can even mix and match add_row and add_column and build add_column ( "Annual Rainfall" ,) Mixing and matching You are adding corresponds to, and a list or tuple which contains the column data: x. Method, which takes two arguments - a string which is the name for the field the column You can add data one column at a time as well. add_rows (, ,, ,, ,, ] ) Column by column When you have a list of rows, you can add them in one go with add_rows: x. The field_names attribute, and then add the rows one at a time using the add_row To do this you can set the field names first using Let's suppose you have a shiny new PrettyTable: from prettytable import PrettyTable x = PrettyTable ()Īnd you want to put some data into it. Tutorial on how to use the PrettyTable API Getting your data into (and out of) the table Or from requirements.txt: -e git:///jazzband/prettytable.git#egg=prettytable Install latest development version: python -m pip install -U git+ Install via pip: python -m pip install -U prettytable | City name | Area | Population | Annual Rainfall | PrettyTable lets you print tables in an attractive ASCII form: +-+-+-+-+
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |