开始学Python

很久没发博客了,最近在学Python玩。贴一波代码:《基本登录系统》

UserList ={'admin':'adminp','user1':'passw1','user2':'passw2'}

def f_u(user):
if user in UserList:
return(0)
else:
return(1)

def check(user,passwrold):
if f_u(user) != 1:
if passwrold == UserList[user]:
return(0)
else:
return(1)

def lock():
try:
lock = open("lock.l",mode="x")
lock.close()
except IOError:
print('错误次数太多禁止登录!')
exit()

lock()

print('****登录系统*****')
i = 3
user = input('用户名:')

while f_u(user) == 1:
print('该用户不存在!请重新输入!')
user = input('用户名:')

passwrold = input('密码:')

while check(user,passwrold) == 1:
i -= 1
if i < 0: lock() print('密码错误!你还有%s次机会!'%(i)) passwrold = input('密码:') print('Welcome!')

One comment

  1. 你可以看看第一篇博文。。我记得有标签是专门放code的 要不然他会忽略掉缩进信息。。

Comments are closed.