try:
f = open('jilu.txt','r')
context = f.read()
print context
except:
print 'you need to check in 3 times'
for i in range(3):
name = raw_input('Please input your name:')
password = raw_input('Please input your password:')
if name == 'hill' and password == '123456':
print 'congratulations! welcome to this!'
break
else:
print 'sorry,your name or password is wrong! please try again'
if i == 2:
f = open('jilu.txt','a+')
f.write('your account is not used')
f.close()
break
转载于:https://blog.51cto.com/hongtengfei/1743015