我是靠谱客的博主 无私未来,这篇文章主要介绍python 表格打印,现在分享给大家,希望可以做个参考。

python 表格打印

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tabledata = [['apples','oranges','cherries','banana'], ['alice','bob','carol','david'], ['dogs','cats','moose','goose']] def themaxlens(table): maxs = 0 for i in range(len(table)): if len(table[i]) >= maxs: maxs = len(table[i]) return maxs def printtable(table): for i in range(len(table[0])): for j in range(len(table)): print(table[j][i].rjust(themaxlens(table[j])),end=' ') print() printtable(tabledata)

最后

以上就是无私未来最近收集整理的关于python 表格打印的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部