标签:存在 lock 错误 int with 用户名 put 认证 nbsp
编写登陆接口
#!/usr/bin/env python # _*_ coding:utf8 _*_ import getpass Username = ‘daxin‘ Password = ‘123456‘ def panduan(name): with open(‘/tmp/result.log‘) as fd: content = fd.read() if len(content) == 0: return True else: lockname = content.split()[0] zhuangtai = content.split()[1] if lockname == name and zhuangtai == ‘lock‘: return False else: return True count = 0 while count < 3: username = raw_input(‘login:‘) password = getpass.getpass(‘password:‘) result = panduan(username) if result: if username == Username and password == Password: print "欢迎登陆" break elif username != Username: print "用户名不存在!,请注册!" break else: print ‘用户名/密码错误‘ break count += 1 else: print ‘帐号已经锁定!‘ break else: print ‘帐号已经锁定!‘ with open(‘/tmp/result.log‘,‘r+‘) as fd: fd.write(‘daxin lock‘)
标签:存在 lock 错误 int with 用户名 put 认证 nbsp
原文地址:http://www.cnblogs.com/dachenzi/p/6105509.html