Python命令行地址簿小程序代码
来源:互联网 发布:财商教育是骗局吗 知乎 编辑:程序博客网 时间:2024/06/02 04:13
# wwei's address book python projectimport cPickle as pimport osimport sysfilename = 'addressbook.data'class Members(object):def __init__(self,name,email,tel):self.name = nameself.email = emailself.tel = teldef tell():f = file(filename)conlist = p.load(f)print conlistf.close()del conlistdef add_or_mod():s = raw_input("pls input a member's msg as 'name,email,tel':")s1 = s.split(',')member = Members(s1[0], s1[1], s1[2])f = file(filename)conlist = p.load(f)conlist[member.name] = member.email +','+ member.telf = file(filename, 'w')p.dump(conlist,f)f.close()del conlist# show the member's msgf = file(filename)conlist = p.load(f)print conlistf.close()def delete():f = file(filename)conlist = p.load(f)d = raw_input("pls enter the name of member you want to delete:")if d in conlist: del conlist[d] f = file(filename,'w') p.dump(conlist,f) print conlist f.close() del conlistelse:print 'the member you enter is not in your address book, pls check'delete()def search():f = file(filename)conlist = p.load(f)s = raw_input("pls input the name of member you want to search:")if s in conlist: print s,':',conlist[s] f.close() del conlistelse:print 'the member you enter is not in your address book, pls check'search()def main():while True:print '-' * 20menu = raw_input('0.show\n1.add or modify\n2.delete\n3.search\nx.EXIT\n')print '-' * 20if menu == '0':tell()elif menu == '1':add_or_mod()elif menu == '2':delete()elif menu == '3':search()elif menu == 'x':sys.exit()else:print 'no this option. pls check'if os.path.exists('addressbook.data'):main()else:f = file(filename, 'w')conlist = {'wwei':'nuaa_2w@163.com,18661616161'}p.dump(conlist,f)f.close()del conlistmain()
0 0
- Python命令行地址簿小程序代码
- Python小程序代码片
- python命令行地址簿程序
- python创建命令行地址簿程序
- python创建命令行地址簿程序
- 小程序代码
- python简明教程练习--命令行 地址簿 程序
- python创建你自己的命令行,地址簿程序
- 用python创建你自己的命令行地址簿程序
- Python:python小手册地址
- C++入门小程序代码
- 喜马拉雅~小程序代码
- opencv各种小程序代码
- 程序代码统计小程序
- 小程序代码开发
- Python的hello程序代码
- 小程序代码寻求帮忙理解
- c语言基础小程序代码
- linux sed命令详解2
- 阿里上市造富运动,致全球富豪榜震荡,马化腾缩水最多,孙正义快要登顶
- Maven学习:使用Nexus搭建Maven私服
- elf 格式简析
- linux 下获得当前目录,上级目录,文件夹名
- Python命令行地址簿小程序代码
- Android通信组件_消息机制_消息传送
- linux sort,uniq,cut,wc命令详解
- 习题三——C语言笔试题
- 【问题汇总】ListView的FooterView设置可见性的问题
- 基于opencv用鼠标在窗口中画矩形和线段的程序
- 串口控制器,电平脉冲触发,顺序轮换,间歇轮换,电磁阀继电器流水,8路,16路,32路
- tr-转换或者删除字符
- 关于document.cookie的使用