def printTable(Data):
for i in range(len(Data[0])):
for y in range(len(Data)):
if y == len(Data) -1 :
dot = '\n'
else:
dot =' '
print(Data[y][i], end=dot)
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
printTable(tableData)
输出如下:
apples Alice dogs
oranges Bob cats
cherries Carol moose
banana David goose
另一种输出方式,右对齐 用rjust
def printTable(Data):
for i in range(len(Data[0])):
for y in range(len(Data)):
if