代码 price={"牛奶":5.5,"可乐":6.7,"饼干":10,"糖果":10} day1={"day":"11.23","牛奶":10,"可乐":10,"饼干":10,"糖果":10} day2={"day":"11.24","牛奶":11,"可乐":11,"饼干":11,"糖果":11} day3={"day":"11.25","牛奶":12,"可乐":12,"饼干":12,"糖果":12} list_day=[day1,day2,day3] for i in list_day: sum=0 money=0 count=0 for k in i.keys(): if k=="day": print(i[k]) else: print(k,":\t数量:",i[k],end="\t") print("单价:",price[k]) money=i[k]*price[k] count+=i[k] sum+=money print("{}今日卖了{}件,共计{:.2f}元".format(i["day"],count,sum)) print()
题目: