小编Sta*_*ins的帖子

自动化镗孔第6章表打印机几乎完成

在本节中,他们希望我们创建此表:

    apples Alice dogs
     oranges Bob cats
 cherries Carol moose
   banana David goose
Run Code Online (Sandbox Code Playgroud)

它必须是正确的,输入是tableData.这是我的代码:

tableData=[['apples', 'oranges', 'cherries', 'banana'],
        ['Alice', 'Bob', 'Carol', 'David'],
        ['dogs', 'cats', 'moose', 'goose']]
listlens=[]
tour=0
lists={}
for m in tableData:
    total=0
    tour+=1
    for n in m:
        total+=len(n)
        lists["list:",tour]=total
    print("list",tour,total)    

itemcount=list(lists.values())
sortedlen=(sorted(itemcount,reverse=True))
longest=sortedlen[0]

#print (lists['list:', 1])
#print (longest)


for m in range(len(tableData[0])):
    for n in range(len(tableData)):
        print (tableData[n][m],end=" ")
        n+=1
    print ("".rjust(lists['list:', 1],"-"))
    m+=1
Run Code Online (Sandbox Code Playgroud)

我差不多完成了一件事,我不能说得对.这个输出是我到目前为止最接近的.

apples Alice dogs ---------------------------
oranges Bob cats ---------------------------
cherries Carol moose ---------------------------
banana …
Run Code Online (Sandbox Code Playgroud)

python printing python-3.x

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

printing ×1

python ×1

python-3.x ×1