Name:LoginAuth.py
Fuctions: Login authentication, hidden input password, the same user 3 times input wrong password lock the account, if the user name is Yooma password is yooma login success Prompt Welcome
Code
#!/usr/bin/env python3#auther:yooma 2016-08-15 15:00import sysimport getpassc = 1uname = []while 1: username = input ("Input Username: ") password = getpass.getpass (" Input password: ") lockfile = open (' Lock.txt ', ' R ') try: if username == lockfile.read (): print ("%s user locked.") % username) sys.exit (0) finally: lockfile.close () if username == ' Yooma ' and password == ' Yooma ': print ("welcome %s login success!" % username) break elif username != ' Yooma ' or password != ' Yooma ': print ("Username or password failed,please input again:") uname.insert (C,username) s = set (uname) for i in s: if c < 4 and uname.count (i) == 3: Lockfile = open (' Lock.txt ', ' W ') try: lockfile.write (username) finally: lockfile.close () print ("your account is locked.") sys.exit (0) elif c == 3: print ("Input Error 3 times,go out. ") sys.exit (0) c+=1 continue &Nbsp; else: print ("Input error.") break
This article is from the "Yooma Technology blog" blog, please be sure to keep this source http://yooma.blog.51cto.com/6965726/1838666
Python Login Validator