标签:
import pickle as p
linkmanfile = ‘linkman.data‘
#the name of the file where we will store the object
linkman = { ‘zhangyunpeng‘ : ‘434498027‘,
‘xuleisen‘ : ‘405929608‘,
‘yinrui‘ : ‘1650502423‘,
‘yancangkuo‘ : ‘1046287430‘,
‘lijizhou‘ : ‘641224214‘,
‘liuyulong‘ : ‘1919734130‘
}
#set up linkman data base
print ‘%d lineman:‘ % len(linkman)
for name, qq in linkman.items():
print ‘%s : %s‘ % (name, qq)
#list original listing
print‘(1-search 2-delete 3-add 0-revise)‘
#prompting of operation
k = int(raw_input(‘please input:‘))
if k == 1:
s = raw_input(‘Search the linkman name:‘)
print ‘%s‘ % linkman[s]
elif k == 2:
d = raw_input(‘delete the linkman name:‘)
del linkman[d]
elif k == 3:
a = raw_input(‘add the linkman name:‘)
A = raw_input(‘add the linkman number:‘)
linkman[a] = A
elif k == 0:
r = raw_input(‘which revise:‘)
linkman[r] = raw_input(‘revised number:‘)
#code of process
for name, qq in linkman.items():
print ‘%s : %s‘ % (name, qq)
#print new listing
f = file(linkmanfile, ‘w‘)
p.dump(linkman, f)
#put data into a file for using next
标签:
原文地址:http://www.cnblogs.com/Lindaman/p/4244792.html