
我寫的程式(沒寫完,不會了)
tableDate=[['hello','world','word','ok'],['hello1','world1','word1','ok1'],['hello2','world2','word2','ok2']]
def printTable(ok):
colWidths=[0]*len(tableDate)
return colWidths
for i in range(len(colWidths)):
colWidths[i]=[0]*len(tableDate[i])
return colWidths[i]
print(printTable(tableDate))
uj5u.com熱心網友回復:
table=[['hello','world','word','ok'], ['hello1','world1','word1','ok1'], ['hello2','world2','word2','ok2']]
ws = [max([len(row[i]) for row in table]) for i in range(len(table[0]))]
for r in table:
print(f'{r[0]:>{ws[0]}} {r[1]:<{ws[1]}} {r[2]:<{ws[2]}} {r[3]:>{ws[3]}}')
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/245363.html
