当然可以!以下是一个简单的工单小程序的示例代码:
```python
# 工单小程序
def create_ticket():
ticket_number = generate_ticket_number()
ticket_category = input("请输入工单类别:")
ticket_description = input("请输入工单描述:")
ticket = {
"ticket_number": ticket_number,
"ticket_category": ticket_category,
"ticket_description": ticket_description,
"status": "待处理"
}
return ticket
def generate_ticket_number():
# 在这里生成唯一的工单号
pass
def display_tickets(tickets):
for ticket in tickets:
print("工单号:", ticket["ticket_number"])
print("工单类别:", ticket["ticket_category"])
print("工单描述:", ticket["ticket_description"])
print("状态:", ticket["status"])
print("---------------------------")
def main():
tickets = []
while True:
print("1. 创建工单")
print("2. 显示工单")
print("3. 退出")
choice = input("请选择:")
if choice == "1":
ticket = create_ticket()
tickets.append(ticket)
print("工单已创建,工单号为:", ticket["ticket_number"])
print("---------------------------")
elif choice == "2":
display_tickets(tickets)
elif choice == "3":
break
else:
print("无效的选择,请重新输入。")
print("---------------------------")
if __name__ == "__main__":
main()
```
这个小程序允许用户创建工单并显示已创建的工单。每个工单有一个唯一的工单号,类别,描述和状态。用户可以选择退出程序或继续操作。您可以根据自己的需求进行修改和扩展。希望这对您有所帮助!