您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在python中创建表?

如何在python中创建表?

您可以为此使用python的制表库。

例如:

>>> from tabulate import tabulate
>>> value_list = [['Alex', 13,1, 'Chess', 10],
                  ['Zia',  12,2, 'Monopoly', 25]]
>>> column_list = ["Name", "Age", "Number of Games", "Favourite Game", "Cost of Game"]
>>> print tabulate(value_list, column_list, tablefmt="grid")
+--------+-------+-------------------+------------------+----------------+
| Name   |   Age |   Number of Games | Favourite Game   |   Cost of Game |
+========+=======+===================+==================+================+
| Alex   |    13 |                 1 | Chess            |             10 |
+--------+-------+-------------------+------------------+----------------+
| Zia    |    12 |                 2 | Monopoly         |             25 |
+--------+-------+-------------------+------------------+----------------+
python 2022/1/1 18:47:43 有319人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶