练习-用户登录

# -*-coding:utf8 -*-
import os

#print(os.getcwd())
users = open('username.txt', 'r')
password = open('password.txt', 'r')
lock_user = open('lock.txt', 'r')

count = 0
while count <3:
user_login = input("Please input your username:")
user_password = input("Please input your password:")
if user_login in lock_user:
print("Your account is locked,please contact admin")
break
elif user_login in users and user_password in password:
print("Welcom {0} login ".format(user_login))
break
else:
print("Your account or password is incorrect !")
if count ==2:
print("You are locked,Please contact admin")
lock_user = open('lock.txt', 'a')
lock_user.write(user_login + '\n')
lock_user.close()
break
else:
user_login_again = input("Would try again,Y/N?")
count += 1
continue
else:
print("locked")
lock_user.close()
posted @ 2017-03-22 22:37  村西崔二  阅读(107)  评论(0编辑  收藏  举报