【发布时间】:2021-05-03 08:12:48
【问题描述】:
如何在 Python 中计算多供应商的运费?
这是我购物车中的数据:
cart = {"line1" : {'vendor1': 1.2,'shipping_cost': 10000,'city': "Manchester",},
"line2" : {'vendor2': 2,'shipping_cost': 20000,'city': "Liverpool",},
"line3" : {'vendor1': 1.2,'shipping_cost': 10000,'city': "Manchester",},
"line4" : {'vendor2': 3,'shipping_cost': 20000,'city': "Liverpool",},
}
我想按供应商计算运费如下:
(vendor1 + vendor1) * shipping_cost = 2.4 * 10.000 = 24.000
(vendor2 + vendor2) * shipping_cost = 5 * 20.000 = 100.000
如何在python中实现这个计算
【问题讨论】:
标签: python-3.x dictionary calculation