# 我们输出的要求是对齐,但是名字的长度不一样 def deal_data(var): for i in range(12-len(var)): # 为什么是12呢?必须保证里面单个长度不能大于12,具体多少可以看自己的每个单元格的数据, 不超过就可以 var += " " return var list1 = [["Jacky", "79", "108621"], ["Lucy", "444", "99"], ["d", "156", "023"], ["Google", "15226", "0233"]] for x in list1: print(deal_data(x[0]), end=" ") print(deal_data(x[1]), end=" ") print(deal_data(x[2]))
标签:输出,表格,deal,print,var,对齐,data From: https://www.cnblogs.com/alpha-cat/p/17375053.html