我有一本字典:import mathimport randomd = {1: ["Spices", math.floor(random.gauss(40, 5))], 2: ["Other stuff", math.floor(random.gauss(20, 5))], 3: ["Tea", math.floor(random.gauss(50, 5))], 10: ["Contraband", math.floor(random.gauss(1000, 5))], 5: ["Fruit", math.floor(random.gauss(10, 5))], 6: ["Textiles", math.floor(random.gauss(40, 5))]}我想將其打印出來,以便與標題很好地對齊。我可以將標題添加到詞典中,并始終確保它們排在最前面嗎?我已經看到了幾種垂直方式進行處理的方法,但我希望它的最大列寬接近于最大str()或int()。例子:鑰匙______標簽______________________編號1______________________香料_____________________42 2______________________其他材料_____________16等顯然,我什至無法在此編輯器中手動執行此操作,但我希望這個想法能夠實現。我也不太想要__。只是一個占位符。
添加回答
舉報
0/150
提交
取消