使用python设计一个淘宝订单管理系统 1. 程序启动,显示淘宝订单管理系统欢迎界面,并显示功能菜单
时间: 2024-03-29 14:37:33 浏览: 29
好的,下面是一个简单的Python淘宝订单管理系统,包含订单查询、订单导出等功能:
```python
import csv
# 订单数据
orders = [
{"订单编号": "1234567", "商品名称": "牛仔裤", "价格": "99.00", "购买数量": "2", "购买人": "张三", "联系电话": "138****1234"},
{"订单编号": "2345678", "商品名称": "T恤", "价格": "49.00", "购买数量": "3", "购买人": "李四", "联系电话": "139****5678"},
{"订单编号": "3456789", "商品名称": "运动鞋", "价格": "199.00", "购买数量": "1", "购买人": "王五", "联系电话": "136****9876"}
]
# 欢迎界面和功能菜单
def print_menu():
print("*" * 30)
print("欢迎使用淘宝订单管理系统")
print("1. 订单查询")
print("2. 订单导出")
print("3. 退出程序")
print("*" * 30)
# 订单查询功能
def search_orders():
keyword = input("请输入订单编号或商品名称:")
result = [order for order in orders if keyword in order["订单编号"] or keyword in order["商品名称"]]
if len(result) == 0:
print("没有查询到相关订单")
else:
print("查询结果如下:")
for order in result:
print(order)
# 订单导出功能
def export_orders():
filename = input("请输入导出文件名:")
with open(filename, "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["订单编号", "商品名称", "价格", "购买数量", "购买人", "联系电话"])
for order in orders:
writer.writerow([order["订单编号"], order["商品名称"], order["价格"], order["购买数量"], order["购买人"], order["联系电话"]])
print("订单已成功导出到文件", filename)
# 程序入口
if __name__ == "__main__":
while True:
print_menu()
choice = input("请输入功能编号:")
if choice == "1":
search_orders()
elif choice == "2":
export_orders()
elif choice == "3":
print("感谢使用淘宝订单管理系统,再见!")
break
else:
print("无效的功能编号,请重新输入")
```
您可以根据需要修改或扩展功能。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)