Python business card management system development

The examples in this article share the development code of the python business card management system for your reference. The specific content is as follows

Use object-oriented development methods to develop business card management system, requiring [file storage] (https://cloud.tencent.com/product/cfs?from=10680) data

# Define business card class
classCard(object):
def __init__(self,name,phone,QQ,Email):
self.name=name
self.phone=phone
self.QQ=QQ
self.Email=Email
def __str__(self):return f"{self.name},{self.phone},{self.QQ},{self.Email}"
# Define business card management class
classCard_mannager(object):
def __init__(self):
self.card_list=[]
# New business card
def new_card(self):
name=input("Please type in your name:")
phone=input("Please enter the phone:")
QQ=input("Please enter QQ:")
Email=input("Please enter Email:")
card=Card(name,phone,QQ,Email)
self.card_list.append(card)
# Show business card
def show_card(self):iflen(self.card_list)0:print("So the business card information is as follows:")print("")for i in self.card_list:print("Name:"+i.name,"phone:"+i.phone,"QQ:"+i.QQ,"Email:"+i.Email)else:print("No such contact information!")
# Find a business card
def search_card(self):
name=input("Please enter the name you are looking for:")for i in self.card_list:if i.name==name:print("Find successful!")print("Name:"+i.name,"phone:"+i.phone,"QQ:"+i.QQ,"Email:"+i.Email)print(" ")print("-"*80)print("1:delete")print("2:modify")print("0:Return to the previous menu")
action=int(input("Please select operation function:"))while True:if action ==1:
self.card_list.remove(i)
self.save_card()print("successfully deleted!")break
elif action==2:
i.name=input("Please type in your name:")
i.phone=input("Please enter the phone:")
i.QQ=input("Please enter QQ:")
i.Email=input("Please enter Email:")
self.save_card()print("Successfully modified!")break
elif action==0:breakelse:print("The input is wrong, please re-enter!")breakbreakelse:print("No such contact information!")
# Save business card
def save_card(self):
flie =open("data.data","w")
cardlist=[i.__dict__ for i in self.card_list]
flie.write(str(cardlist))
flie.close()
# Load business card
def load_card(self):try:
flie =open("data.data","r")
except:
flie =open("data.data","w")else:
data=eval(flie.read())iflen(data)0:for i in data:
card=Card(i["name"],i["phone"],i["QQ"],i["Email"])
self.card_list.append(card)finally:
flie.close()
# menu
@ staticmethod
def show_menu():print("*"*80)print("Welcome to use [Business Card Management System] V2.0")print()print("1.New business card")print("2.Show all business cards")print("3.Query business cards")print()print("0.Exit system")print("*"*80)
def run(self):
self.load_card()while True:
self.show_menu()
action=int(input("Please select operation function:"))print("Your choice is:{0}".format(action))if action==1:
self.new_card()
self.save_card()print("Added successfully!")
elif action==2:
self.show_card()
elif action==3:
self.search_card()
elif action==0:print("Welcome to use again!")breakelse:print("The input is wrong, please re-enter!")if __name__=="__main__":
A=Card_mannager()
A.run()

For more learning materials, please pay attention to the topic "Management System Development".

The above is the whole content of this article, I hope it will be helpful to everyone's study.

Recommended Posts

Python business card management system development
Python realizes business card management system
Python3 realizes business card management system
Python version business card management system
Python implements a simple business card management system
Use python to realize business card management system
Implementation of business card management system with python
Implementation of business card management system based on python
Python realizes the development of student management system
Python implements parking management system
Python implements car management system
Implementing student management system with python
Implementation of python student management system
centos system management
Context management in Python
Python crawler gerapy crawler management
Centos system process management
Python runtime exception management solution
Python realizes face sign-in system
ubuntu build python development environment
Python3 interface development commonly used.md