python购物车之用户部分代码

知识点: 文件读,写操作,if 判断, for 循环

salary = input(“输入你的工资:”)
bought_list = []
product_list = {}
with open(“product_list”,”r”,encoding=”utf-8″) as f1:
for item in f1:
p_name,p_price = item.strip().split(‘:’)
product_list[p_name]=int(p_price)
print(product_list)
if salary.isdigit():
salary = int(salary)
while true:
user_choice = input(“please input product which you want:”)
if user_choice in product_list.keys():
if product_list[user_choice]

Posted in 未分类

发表评论