我有一本字典:
import math
import random
d = {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
等
显然,我什至无法在此编辑器中手动执行此操作,但我希望这个想法能够实现。我也不太想要__。只是一个占位符。
相关分类