python
# 15-购物小票还原
def main():
keys=['商品名称','单价','数量','折扣']
new_DIC=dict.fromkeys(keys,'sss')
print(new_DIC)
commoditys=[{'商品名称': '土豆', '单价':1.32, '数量':6, '折扣':0.9},{'商品名称': '茄子', '单价':1.1, '数量':2, '折扣':1},
{'商品名称': '西红柿', '单价':4, '数量':4, '折扣':1},{'商品名称': '白菜', '单价':0.6, '数量':10, '折扣':0.8},
{'商品名称': '大葱', '单价':1.52, '数量':3, '折扣':0.9},{'商品名称': '辣椒', '单价':2, '数量':6, '折扣':0.89}]
for commodity in commoditys:
cmmoditycost = commodity['单价']*commodity['数量']*commodity['折扣']
print(commodity['商品名称'],'的花费是:',cmmoditycost)
cmmoditycost+=cmmoditycost
print('共计花费',cmmoditycost )
if __name__ == '__main__':
main()
结果: