I have a dictionary:
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))]
}
I want to print it out so it lines up nicely with headers. Can I add the headers to the dictionary and always be sure they come out on top?
I've seen a few ways to do it vertically but I'd like to have it come out with max column widths close to the max str() or int().
Example:
Key___________________Label______________________Number
1______________________Spices_____________________42
2______________________Other Stuff_____________16
etc
Apparently I can't even do this inside of this editor manually, but I hope the idea comes across.
I also don't really want the __ either. Just a place holder.
Thanks all.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…