python作业
人力资源。创建一个简单的雇员姓名和编号的程序。让用户输入一组雇员姓名和编号。你的程序可以提供按照编号排序输出数据!#!/bin/env python#coding=utf-8do = raw_input ("what do you want to do? a:add q:quit\n")a = {}def hanshu():if do == "a":
·
一、人力资源。创建一个简单的雇员姓名和编号的程序。让用户输入一组雇员姓名和编号。你的程序可以提供按照编号排序输出数据!
#!/bin/env python
#coding=utf-8
do = raw_input ("what do you want to do? a:add q:quit\n")
a = {}
def hanshu():
if do == "a":
user = raw_input ("please input username:\n")
password = raw_input ("please input number:\n")
a.update({user:password})
def tou():
h = raw_input ("if you want continue,please input c,or input q!\n")
if h == "q":
print "bye-bye\n"
elif h == "c":
hanshu()
else:
print "you's input error! please input agin!\n"
tou()
tou()
else:
print "bye-bye\n"
hanshu()
i= sorted(a.items(),key=lambda item:item[1])
print "########################"
for p,q in i:
print p,q
二、创建一个登陆脚本:
#conding=utf-8
a = raw_input ("please input user:")
b = raw_input ("please input password:")
dic = {"zhaoxin":"zhaoxin","dema":"dema","weien":"weien"}
def delete():
d = raw_input ("please input deletes username: ")
if d == dic.get(d):
if d == dic.get(a):
print "you can't delete runing user!"
delete()
else:
del dic[d]
print "delete success!"
print "###################"
print "username password"
for p,q in dic.items():
print p,q
else:
print "your's input error,please try agin!"
delete()
def show():
print "###################"
print "username password"
for p,q in dic.items():
print p,q
def zhu():
if a in dic.keys():
if b == dic.get(a):
print "OK!"
print "Hi dear! you can do it!"
print '''
D:delete a user!
S:show all user and password!
E:exit!
'''
c = raw_input ("What do you want to do?\n")
if c == "d":
delete()
elif c == "s":
show()
else:
pass
else:
print "user's password error,please try agin!"
else:
print "your's input error,please try agin!"
zhu()
更多推荐
已为社区贡献11条内容
所有评论(0)