0

10~12番のくぼみの消し方 9番までは数字によるくぼみがないので問題ありません。

mList = [" Ganja Masta"," Chicken"," Supreme"," Hawaiian"," God Father"," Double Cheese"," Vegetarian"," Meat Lovers"," Beef and BBQ","Fire Breather","Mr Wedge","Double Bacon"]
pList = [8.50,8.50,8.50,8.50,8.50,8.50,8.50,13.50,13.50,13.50,13.50,13.50]
qList = [0,0,0,0,0,0,0,0,0,0,0,0,0]
tList = [0,0,0,0,0,0,0,0,0,0,0,0]
cList = ["Delivery","delivery","Pickup","pickup","PickUp","pick-up","Pick-up","Pick-Up"]
dList = ["Delivery","delivery"]

print("Code No     Item               Price         Quantity        Item Total")
print("=======================================================================")
for count in range(len(mList)):
    print("{0}          {1:<15}    ${2:>5.2f}      {3:>5}               ${4:>5.2f}".format(count+1,mList[count],pList[count],qList[count],tList[count]))
4

2 に答える 2

0

表を印刷するだけです:

table=[
    ["Code No", "Item", "Price", "Quantity", "Item Total"],
     [1,'Ganja Masta',    8.50,          0,        0.00],
     [2,'Chicken',        8.50,          0,        0.00],
     [3,'Supreme',        8.50,          0,        0.00],
     [4,'Hawaiian',       8.50,          0,        0.00],
     [5,'God Father',     8.50,          0,        0.00],
     [6,'Double Cheese',  8.50,          0,        0.00],
     [7,'Vegetarian',     8.50,          0,        0.00],
     [8,'Meat Lovers',   13.50,          0,        0.00],
     [9,'Beef and BBQ',  13.50,          0,        0.00],
    [10,'Fire Breather', 13.50,          0,        0.00],
    [11,'Mr Wedge',      13.50,          0,        0.00],
    [12,'Double Bacon',  13.50,          0,        0.00]
    ]

def printTable (tbl, borderHorizontal = '-', borderVertical = '|', borderCross = '+'):
    cols = [list(x) for x in zip(*tbl)]
    lengths = [max(map(len, map(str, col))) for col in cols]
    f = borderVertical + borderVertical.join(' {:>%d} ' % l for l in lengths) + borderVertical
    s = borderCross + borderCross.join(borderHorizontal * (l+2) for l in lengths) + borderCross

    print(s)
    for row in tbl:
        print(f.format(*row))
        print(s)    

printTable(table)   
于 2013-10-25T00:54:13.813 に答える