码迷,mamicode.com
首页 > 编程语言 > 详细

第一个python程序

时间:2015-01-23 19:54:12      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

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

第一个python程序

标签:

原文地址:http://www.cnblogs.com/Lindaman/p/4244792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!