我有這個樣本資料。
table_data = {
"name": ['avery','john', 'jonas', 'jordan', 'terry', 'jared', 'evan'],
"number": [0, 3, 8, 6, 12, 7, 11],
"position": ['pg', 'sg', 'pf', 'pf', 'pg', 'c', 'sg'],
"age": [25, 27, 29, 21, 22, 31, 27],
"team": ['boston celtic',
'boston celtic',
'boston celtic',
'boston celtic',
'boston celtic',
'boston celtic',
'boston celtic', ],
}
我想以表格形式顯示這些資料,帶有像
uj5u.com熱心網友回復:
所以這就是我要做的事情:
table_data = {
"name": ['avery', 'john', 'jonas', 'jordan', 'terry', 'jared', 'evan'],
"number": [0, 3, 8, 6, 12, 7, 11],
"position": ['pg', 'sg', 'pf', 'pf', 'pg', 'c', 'sg'],
"age": [25, 27, 29, 21, 22, 31, 27],
"team": ['boston celtic',
'boston celtic',
'boston celtic',
'boston celtic',
'boston celtic',
'boston celtic',
'boston celtic', ],
}
for i in table_data["name"]:
pos = table_data["name"].index(i)
print(f"""{i}\t{table_data["age"][pos]}\t{table_data["position"][pos]}\t{table_data["team"][pos]}\t{table_data["number"][pos]}""")
輸出:
avery 25 pg boston celtic 0
john 27 sg boston celtic 3
jonas 29 pf boston celtic 8
jordan 21 pf boston celtic 6
terry 22 pg boston celtic 12
jared 31 c boston celtic 7
evan 27 sg boston celtic 11
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/436670.html
上一篇:帶有保存點的延遲約束觸發器
下一篇:從嵌套串列/元組創建多輸入字典
