使用python完成手机商品简易进销存系统程序,要求如下: (1) 手机商品内容应至少包含id号,名称,价格,数量,例如: products = [{"id": 1, "name": "华为Mate50", "price": 6000, "quantity": 100}, (2) 系统具有以下功能: 功能菜单(也是入口程序运行后出现的界面,用户可在此界面进行功能选择) 管理商品(即商品信息的录入删除与修改,先判断欲管理的商品是否在商品数据库,如无则新增该商品,如有则进行商品信息录入删除或修改) 进货(即增加商品数量,先判断欲录入的商品是否在商品数据库,如是则修改数量,如否则询问是否要进入管理商品功能) 销货(即减少商品数量,先判断欲销售的商品是否在商品数据库,如是则根据用户购买需要修改数量,根据情况进入进货功能或产生销售行为) 查货(即查询商品库存情况和销售情况,根据用户输入的商品名称、id号、商品数量进行查询,要求支持商品名称模糊查询,如查询“为”应能检索到“华为Mate50”的商品信息,如有查询结果则询问是否要进入销货系统,根据选择进入销货系统或功能菜单) (3) 实现的功能与过程要符合合理好用的原则,如功能模块之间的跳转应合理,数据输入过程应有数据检验:例如输入购买商品id不在库存商品范围内应报错、输入超过库存数量的购买商品数量、输入明显错误的数量或价格也应报错(如输入负数)等等; (4) 数据应符合准确原则,其变化添减应准确且符合商品进销存管理的逻辑要求; (5) 可合理自行决定在开发过程中使用函数、类、对象、第三方库(模块)等开发代码,方便代码的理解与组织部署; (6) 所有数据均要求保存在SQLITE3库中,界面可使用字符型界面。 (7) 可选要求:程序界面可使用字符型界面,也可使用类似tkinker的图形界面进行设计,鼓励使用图形界面,使用图形界面的作品将酌情增加不超过8分的附加分。
时间: 2023-02-06 20:19:39 浏览: 241
To create a simple mobile phone inventory management system in Python, you can start by defining a list of products with dictionaries containing at least an "id" number, a "name", a "price", and a "quantity" for each product. For example:
```
products = [{"id": 1, "name": "华为Mate50", "price": 6000, "quantity": 100},
{"id": 2, "name": "苹果iPhone12", "price": 7000, "quantity": 80},
{"id": 3, "name": "小米MIX4", "price": 5000, "quantity": 120}]
```
To create the menu for the system, you can use a while loop to continuously display a list of options and prompt the user to make a selection. For example:
```
while True:
print("1. 管理商品")
print("2. 进货")
print("3. 销货")
print("4. 查货")
print("5. 退出系统")
choice = input("请输入你的选择: ")
if choice == "1":
# 管理商品功能
pass
elif choice == "2":
# 进货功能
pass
elif choice == "3":
# 销货功能
pass
elif choice == "4":
# 查货功能
pass
elif choice == "5":
# 退出系统
break
else:
print("无效的选择, 请重新输入")
```
To implement the "管理商品" (manage products) function, you can prompt the user to enter the "id" or "name" of the product they want to manage, and then use a for loop to search the "products" list for a match. If a match is found, you can display the current product information and prompt the user to enter new values for the "price" and "quantity" or delete the product. If no match is found, you can prompt the user to add a new product.
To implement the "进货" (add stock) function, you can follow a similar process as above to search the "products" list for a match, and then prompt the user to enter the amount of stock they want to add. If no match is found, you can prompt the user to either add a new product or return to the main menu.
To implement the "销货" (sell products) function, you can follow a similar process as above to search the "products" list for a match, and then prompt the user to enter the number of products they want to sell. If the product is in stock, you can update the "quantity" and display the total cost of the sale. If the product is out of stock, you can prompt the user to either restock the product or return to the main menu.
To implement the
阅读全文