开始学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!')

《打火机与公主裙》

"公主殿下,高考是一道分水岭。"
"什么分水岭?"
"从它结束的那一刻起,人光凭努力就能做好的事情,就越来越少了。"

——Twentine《打火机与公主裙》