python3 写一个CRM代码
时间: 2024-03-28 21:13:33 浏览: 11
好的,下面是一个简单的CRM代码实现,具体功能包括添加客户、显示客户列表、查找客户、删除客户等。
```python
class Customer:
def __init__(self, name, phone, email):
self.name = name
self.phone = phone
self.email = email
class CRM:
def __init__(self):
self.customers = []
def add_customer(self, customer):
self.customers.append(customer)
print("客户添加成功!")
def show_customers(self):
if self.customers:
print("客户信息如下:")
for c in self.customers:
print(f"姓名:{c.name},电话:{c.phone},邮箱:{c.email}")
else:
print("暂无客户信息!")
def find_customer(self, name):
for c in self.customers:
if c.name == name:
print(f"姓名:{c.name},电话:{c.phone},邮箱:{c.email}")
return
print("未找到该客户!")
def del_customer(self, name):
for c in self.customers:
if c.name == name:
self.customers.remove(c)
print(f"{name}客户删除成功!")
return
print("未找到该客户!")
if __name__ == '__main__':
crm = CRM()
while True:
print("=" * 30)
print("1.添加客户\n2.显示客户列表\n3.查找客户\n4.删除客户\n5.退出系统")
print("=" * 30)
choice = input("请输入数字选择相应功能:")
if choice == "1":
name = input("请输入客户姓名:")
phone = input("请输入客户电话:")
email = input("请输入客户邮箱:")
crm.add_customer(Customer(name, phone, email))
elif choice == "2":
crm.show_customers()
elif choice == "3":
name = input("请输入客户姓名:")
crm.find_customer(name)
elif choice == "4":
name = input("请输入客户姓名:")
crm.del_customer(name)
elif choice == "5":
print("欢迎下次使用!")
break
else:
print("输入错误,请重新输入!")
```
以上代码实现比较简单,如果需要更多功能可以根据需求自行添加。