python实现名⽚管理系统(代码)废话不多说直接上代码
(适合新⼿理解和练习,可在此基础进⾏扩展)
主函数
main.py
import home
import add_IDcard
import show_IDcard
import query_IDcard
if __name__ =="__main__":
card_info_list =[]
while True:
home.home()
select =input("请输⼊:")
print(card_info_list)
if select =='1':
card_info_list = add_IDcard.add_info(card_info_list)
elif select =='2':
show_IDcard.show_all(card_info_list)
elif select =='3':
card_info_list = query_IDcard.query_all(card_info_list)
elif select =='0':
print("您已退出!")
break
else:
print("输⼊有误!")
home.py(⽤于显⽰主界⾯)
def home():
print("*"*20)
print("欢迎使⽤名⽚管理系统v1.0")
print()
print("1、新建名⽚")
print("2、显⽰全部")
print("3、查询名⽚")
print()
print("0、退出系统")
print("*"*20)
add_IDcard.py(新增名⽚)
import home
def add_info(card_info_list):
while True:
print("******新增信息中******")
name =input("请输⼊名字:")
tel =input("请输⼊电话号码:")
qq =input("请输⼊qq号码:")
e_mail =input("请输⼊邮箱地址:")
dict_tmp ={}
dict_tmp["姓名"]= name
dict_tmp["电话号码"]= tel
dict_tmp["QQ"]= qq
dict_tmp["邮箱"]= e_mail
card_info_list.append(dict_tmp)
#print(card_info_list)
#dict_tmp.clear()
print("******新增完成******")
print("1、继续新增(任意键返回主界⾯)")
select =input("请输⼊:")
if select !='1':
return card_info_list
show_IDcard.py(显⽰全部名⽚信息)
import home
def show_all(card_info_list):
count =1
print("********************全部信息***********************") for card_info in card_info_list:
print("联系⼈%d"%count)
#print(card_info)
for i in card_info.keys():
print("%s----%s"%(i,card_info[i]))
count +=1
print("*********************显⽰完毕***********************") #2
# home.home()
def show_one(card_info):
for i in card_info:
print("%s----%s"%(i,card_info[i]))
query_IDcard.py(查询、修改、删除)
import show_IDcard
import home
def query_all(card_info_list):
query_key =input("请输⼊查内容:")
for card_info in card_info_list:
for i in card_info.values():
if query_key in i:
show_IDcard.show_one(card_info)
print("1、修改    2、删除")
select =input("请输⼊:")
if select =='1':
card_info_list = update(card_info_list, card_info)
return  card_info_list
elif select =='2':
card_info_list = delete(card_info_list, card_info)
return card_info_list
else:
print("输⼊不合法!")
break
break
else:
print("未到该联系⼈信息!")
print("1、继续查询  2、返回主界⾯")
select =input("请输⼊:")
if select =='2':
home.home()
elif select =='1':
query_all(card_info_list)
else:
print('输⼊不合法!返回主界⾯')
def update(card_info_list, card_info):
new_card_info = modify(card_info)
card_ve(card_info)
card_info_list.append(new_card_info)
return card_info_list
def modify(card_info):
python新手代码userid
flag =1
while flag:
print('1、姓名  2、电话号码    3、QQ    4、邮箱  (其他任意数字结束修改!)')        select =input('请输⼊:')
if select =='1':
card_info['姓名']=input("输⼊新姓名:")
elif select =='2':
card_info['电话号码']=input('输⼊新电话号码:')
elif select =='3':
card_info['QQ']=input("输⼊新QQ:")
elif select =='4':
card_info['邮箱']=input('输⼊新邮箱:')
else:
flag =0
return card_info
def delete(card_info_list, card_info):
card_ve(card_info)
return card_info_list
**
创作不易,希望⼤家多多⽀持指正!!!
**

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。