Implementation of business card management system based on python

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

Main Program:

import cards_tools
# Infinite loop, the user decides when to exit
while True:
# TODO comments, used to mark the work that needs to be done

 cards_tools.show_menu()

 action_str =raw_input("Please select the operation you want to perform: ")print("The operation you choose is%s"% action_str)
 # 1,2,3 Operations for business cards
 if action_str in["1","2","3"]:if action_str =="1":
 cards_tools.new_card()
 elif action_str =="2":
 cards_tools.show_all()
 elif action_str =="3":
 cards_tools.search_card()

 # 0 Exit system
 elif action_str =="0":print("Welcome to use [Business Card Management System] again:")break
 # If you do not want to write the code inside the branch immediately when you are developing the program
 # You can use the pass keyword to represent a placeholder to ensure that the code structure of the program is correct
 # When running the program, the pass keyword does nothing
 else:print("Input errors, please re-enter:")

ProgramToolkit:

card_list =[]
def show_menu():"""Show menu"""
print '*'*50
print 'Welcome to [Business Card Management System]'
print ''
print '1.Add business card'
print '2.display all'
print '3.Search for business cards'
print '0.Exit system'
print '*'*50
def new_card():"""Add business card"""
print '-'*50
print 'Add business card'
# 1. Prompt the user to enter the details of the business card
name_str =raw_input('Please type in your name:')
phone_str =raw_input('Please enter the phone:')
qq_str =raw_input('Please enter QQ:')
email_str =raw_input('please input your email:')
# 2. Use the information entered by the user to build a business card dictionary
card_dict ={'name_str': name_str,'phone_str': phone_str,'qq_str': qq_str,'email_str': email_str}
# 3. Add business card dictionary to the list
card_list.append(card_dict) #Append a dictionary to a list
print card_list
# 4. Prompt the user to add successfully
print 'Add to%s'business card success'% name_str
def show_all():"""Show all business cards"""
print '-'*50
print 'Show all business cards'
# Determine whether there is a business card record, if not, prompt the user and return
iflen(card_list)==0:
print 'There is currently no business card record, please use the new function to add a business card'
# return can return the execution result of a function
# The code below will not be executed
# If there is nothing after return, it means that it will return to the place where the function was called
# And returns no results
return
# Print head
for name in["Name","phone","QQ","mailbox"]:
print name,
print ''
# Print divider
print '='*50
# Traverse the list of business cards and output dictionary information in turn
for card_dict in card_list:
# print card_dict
print '%stt%stt%stt%s'%(card_dict['name_str'],
card_dict['phone_str'],
card_dict['qq_str'],
card_dict['email_str'])
def search_card():"""Search for business cards"""
print '-'*50
print 'Search for business cards'
# 1. Prompt the user to enter the name to search
find_name =raw_input('Please enter the name to be searched:')
# 2. Traverse the list of business cards, query the name to be searched, if not found, you need to prompt the user
for card_dict in card_list:if card_dict['name_str']== find_name:
print 'Name Phone QQ Email'
print '='*50
print '%s %s %s %s'%(card_dict['name_str'],
card_dict['phone_str'],
card_dict['qq_str'],
card_dict['email_str'])
# TODO performs modification and deletion operations on the business card records found
# In our daily writing programs, if there is too much code for a function, it is difficult to read and write. In development, a function can be encapsulated for a specific independent function, and this function will handle the specific Operation, so that we can ensure that the code in each function is clear and clear, and the function is clear
deal_card(card_dict)breakelse:
print 'Sorry, not found%s'% find_name
def deal_card(find_dict):
print find_dict
action_str =raw_input('Please select the action to be performed''[1]modify[2]delete:')
# Replace existing key-value pairs
if action_str =='1':
find_dict['name_str']=input_card_info(find_dict['name_str'],'Name:')
find_dict['phone_str']=input_card_info(find_dict['phone_str'],'phone:')
find_dict['qq_str']=input_card_info(find_dict['qq_str'],'QQ:')
find_dict['email_str']=input_card_info(find_dict['email_str'],'mailbox:')
print 'Successfully modified the business card! ! !'
elif action_str =='2':
card_list.remove(find_dict)
print 'Successfully deleted the business card! ! !'
def input_card_info(dict_value, tip_message):"""
: param dict_value:The original value in the dictionary
: param tip_message:Prompt text
: return:If the user enters the content, it returns the content and is responsible for returning the original value in the dictionary
"""
# 1. Prompt the user for input
result_str =raw_input(tip_message)
# 2. Judge the user's input, if the user enters the content, return the result directly
iflen(result_str)0:return result_str
# 3. If the user does not input content, return the original value in the dictionary'
else:return dict_value

Realization effect:

/usr/bin/python2.7/home/kiosk/PycharmProjects/python/Fourth day/Comprehensive application-Business Card Management System/cards_main.py
**************************************************
Welcome to [Business Card Management System]
1. Add business card
2. display all
3. Search for business cards
0. Exit system
**************************************************
Please select the operation you want to perform:2
The operation you choose is 2--------------------------------------------------
Show all business cards
There is currently no business card record, please use the new function to add a business card
**************************************************
Welcome to [Business Card Management System]
1. Add business card
2. display all
3. Search for business cards
0. Exit system
**************************************************
Please select the operation you want to perform:1
The operation you choose is 1--------------------------------------------------
Add business card
Please enter your name: Xue Feilong
Please enter the phone: 123456
Please enter QQ: 456123
Please enter email: [email protected]
[{' qq_str':'456123','name_str':'xe8x96x9bxe9xa3x9exe9xbex99','phone_str':'123456','email_str':'[email protected]'}]
Successfully added Xue Feilong's business card
**************************************************
Welcome to [Business Card Management System]
1. Add business card
2. display all
3. Search for business cards
0. Exit system
**************************************************
Please select the operation you want to perform:3
The operation you choose is 3--------------------------------------------------
Search for business cards
Please enter the name to be searched: Xue Feilong
Name Phone QQ Email
==================================================
Xue Feilong [email protected]
{' qq_str':'456123','name_str':'xe8x96x9bxe9xa3x9exe9xbex99','phone_str':'123456','email_str':'[email protected]'}
Please select the action to be performed[1]modify[2]delete:1
Name: Xiang Yuanyuan
phone:
QQ:
mailbox:
Successfully modified the business card! ! !
**************************************************
Welcome to [Business Card Management System]
1. Add business card
2. display all
3. Search for business cards
0. Exit system
**************************************************
Please select the operation you want to perform:2
The operation you choose is 2--------------------------------------------------
Show all business cards
Name Phone QQ Email
==================================================
Xiang Yuanyuan [email protected]
**************************************************
Welcome to [Business Card Management System]
1. Add business card
2. display all
3. Search for business cards
0. Exit system
**************************************************
Please select the operation you want to perform:0
The operation you selected is 0
Welcome to use [Business Card Management System] again:

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

Implementation of business card management system based on python
Implementation of business card management system with python
Python realizes business card management system
Python3 realizes business card management system
Python business card management system development
Python version business card management system
Implementation of python student management system
Python implements a simple business card management system
Use python to realize business card management system
Python realizes the development of student management system
Detailed explanation of data types based on Python
Diagram of using Python process based on FME
Solve the problem of convex hull based on python
Detailed explanation of the remaining problem based on python (%)
Python implements parking management system
Python implements car management system
Python implementation of gomoku program
Detailed implementation of Python plug-in mechanism
Python implementation of IOU calculation case
Implementing student management system with python
Python preliminary implementation of word2vec operation
Implementation of python selenium operation cookie
Implementation of python3 registration global hotkey
Implementation of python gradient descent algorithm
Basic analysis of Python turtle library implementation
Draw personal footprint map based on Python
Implementation of JWT user authentication in python
Implementation principle of dynamic binding of Python classes
Check matrix calculation results based on python
Some basic optimizations of Centos6.9 system (updated on 2018/04/19)
How to program based on interfaces in Python
[Practice] How to install python3.6 on Ubuntu system
Python implements SSL sending based on QQ mailbox
Implementation of Python headless crawler to download files
Common command usage of nmcli based on RHEL8/CentOS8
Python implementation of AI automatic matting example analysis
Python implementation of hand drawing effect example sharing
Python writes the game implementation of fishing master