python快递管理系统500行
时间: 2023-07-21 10:59:40 浏览: 97
基于Python+SQL Server2008实现(GUI)快递管理系统【100010068】
5星 · 资源好评率100%
当然,我可以为您提供一个大致为500行的简单Python快递管理系统示例。请注意,这只是一个基本的示例,可能不包含所有的功能和错误处理。
```python
class Package:
def __init__(self, tracking_number, sender, recipient):
self.tracking_number = tracking_number
self.sender = sender
self.recipient = recipient
self.status = "In transit"
class DeliverySystem:
def __init__(self):
self.packages = []
def add_package(self, tracking_number, sender, recipient):
package = Package(tracking_number, sender, recipient)
self.packages.append(package)
def update_status(self, tracking_number, status):
for package in self.packages:
if package.tracking_number == tracking_number:
package.status = status
break
def get_package_status(self, tracking_number):
for package in self.packages:
if package.tracking_number == tracking_number:
return package.status
return "Package not found"
def main():
delivery_system = DeliverySystem()
while True:
print("1. Add package")
print("2. Update package status")
print("3. Get package status")
print("4. Quit")
choice = input("Enter your choice: ")
if choice == "1":
tracking_number = input("Enter tracking number: ")
sender = input("Enter sender name: ")
recipient = input("Enter recipient name: ")
delivery_system.add_package(tracking_number, sender, recipient)
print("Package added successfully!")
elif choice == "2":
tracking_number = input("Enter tracking number: ")
status = input("Enter new status: ")
delivery_system.update_status(tracking_number, status)
print("Status updated successfully!")
elif choice == "3":
tracking_number = input("Enter tracking number: ")
status = delivery_system.get_package_status(tracking_number)
print("Package status:", status)
elif choice == "4":
break
else:
print("Invalid choice. Try again.")
if __name__ == "__main__":
main()
```
这是一个基本的快递管理系统,其中`Package`类表示一个快递包裹,`DeliverySystem`类表示整个快递系统。您可以通过添加、更新和获取快递包裹的状态来与系统进行交互。请注意,此示例仅用于演示目的,实际应用中可能需要更多的功能和改进。
阅读全文