Python realizes business card management system

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

system requirement

Program starts, displays the welcome interface of the business card management system, and displays the function menu


Welcome to use [Business Card Management System] V1.0
?

  1. New business card
  2. display all
  3. Query business cards
    ?
  4. Exit system

demand analysis

Code

The code is very concise, and too many comments can be messy.

cards_main.py

import cards_tool
# Main business logic
cards_tool.read_card()
 
 
# 1. Display the main user interface
while True:
 cards_tool.show_menu()
 menu_str =input("Please choose an action:")print("The function you choose:%s"% menu_str)if menu_str =="1":
 cards_tool.create_card()
 elif menu_str =="2":
 cards_tool.show_card_all()
 elif menu_str =="3":
 cards_tool.search_card()
 elif menu_str =="0":
 cards_tool.write_card()breakelse:print("The input is wrong, please re-enter")

cards_tool.py

import os
card_info_all =[] #All business card information
# Specific functions of business card management
def write_card():"""When exiting the system, save the business card information to the folder"""
f =open("E:\workspace_python\FirstDemo\Business Card Management System.txt","w")
f.write(str(card_info_all))
f.close()
def read_card():"""When entering the system, load the business card information into the memory"""
is_exist = os.path.exists("E:\workspace_python\FirstDemo\Business Card Management System.txt")if is_exist:
# File exists, load information into memory
f =open("E:\workspace_python\FirstDemo\Business Card Management System.txt","r")
global card_info_all
card_info_all =eval(f.read())
# print(card_info_all)
f.close()else:
# No file creates empty file
f =open("E:\workspace_python\FirstDemo\Business Card Management System.txt","w")
f.close()print(is_exist)
def show_menu():"""Main menu page display"""print("*"*30)print("welcome[Naming Management System] v1.0")print()print("1.New business card")print("2.display all")print("3.Query business cards")print()print("0.Exit system")print("*"*30)
def create_card():"""New business card"""print("功能:New business card")
name =input("Please type in your name:")
phone =input("Please enter the phone:")
qq =input("Please enter qq number:")
email =input("please input your email:")
card_info ={"name":name,"phone":phone,"qq":qq,"email":email}
card_info_all.append(card_info)print("Add to%s'business card success"% name)
def show_card_all():"""Show all business cards"""print("Function: show all")if not len(card_info_all):print("No business card")returnprint("name".ljust(14),"phone".ljust(14),"qq".ljust(14),"email".ljust(14),sep="")print("-"*56)for card in card_info_all:print(card["name"].ljust(14),card["phone"].ljust(14),card["qq"].ljust(14),card["email"].ljust(14),sep="")print("-"*56)
def search_card():"""Query business cards"""print("功能:Query business cards")
name =input("Please enter the query name:")for card in card_info_all:if name == card["name"]:print("name".ljust(14),"phone".ljust(14),"qq".ljust(14),"email".ljust(14), sep="")print("-"*56)print(card["name"].ljust(14), card["phone"].ljust(14), card["qq"].ljust(14), card["email"].ljust(14),sep="")
# Advanced business card processing
set_card(card)break;else:print("could not find it%s"% name)
def set_card(card):"""Advanced settings for business cards"""while True:
menu =input("Please enter the operation on the business card: 1.modify/ 2.delete/ 0.Back to previous")if menu =="1":
name =input("Please type in your name:")
phone =input("Please enter the phone:")
qq =input("Please enter qq number:")
email =input("please input your email:")
card["name"]= name
card["phone"]= phone
card["qq"]= qq
card["email"]= email
print("%s's business card was modified successfully"% name)return
elif menu =="2":
card_info_all.remove(card)print("Successfully deleted business card")return
elif menu =="0":returnelse:print("The input is wrong, please re-enter")

Code running result

Exercise summary

This small exercise is mainly a comprehensive application of the basic knowledge of python. You must master the basic knowledge of python. Does it feel simple for friends who have experience in other programming languages?

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 your study, and I hope you can support website (zalou.cn).

Articles you may be interested in:

Recommended Posts

Python realizes business card management system
Python3 realizes business card management system
Python business card management system development
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
Python realizes face sign-in system
Implementing student management system with python
Python realizes express price query system
Implementation of python student management system
centos system management
Python realizes spaceship war
Python realizes stitching pictures
Context management in Python
Python crawler gerapy crawler management
Python realizes online translation
Python realizes tank battle
Centos system process management
Python3 realizes airplane war game
Python realizes online translation function
Python runtime exception management solution
Python realizes apple eating game
Python realizes the guessing game
Python realizes 3D map visualization
Python realizes batch naming photos