把列表products转换为字典形式,并访问键值为'Iphone'的值,然后更改键值为'Iphone'的值为2000。

 把列表products转换为字典形式,并访问键值为'Iphone'的值,然后更改键值为'Iphone'的值为2000。

列表具体长啥样,有哪些内容,你都不用说明一下的吗?


products = ["Iphone", "Mac", "iwatch"]
# 转换为字典
dict_temp = {}
for product in products:
    dict_temp[product] = 0
print(dict_temp)

# 修改Iphone的值
dict_temp['Iphone'] = 2000
print(dict_temp)