您好,欢迎来到小侦探旅游网。
搜索
您的当前位置:首页Python购物车之商家部分代码

Python购物车之商家部分代码

来源:小侦探旅游网

知识点:文件写入操作, 函数, 函数递归

#!C:Program FilesPython35/bin
# -*- conding:utf-8 -*-
# author: Frank

# 定义商品列表
product_list = {
 'Pen':2.5,
 'NoteBook':3.3,
 'eraser':1.0
}

Mesg = '''
1.Change goods' price
2.Add new goods
3.quit
Plese input which do you want :
'''
def print_list():
 for key in product_list:
 print(key, product_list[key])

def change_price():
 name = input("please input the goods name:")
 if name in product_list:
 new_price = input("please input new price:")
 product_list[name] = new_price
 print("