#! /usr/bin/python
# Coding:utf-8
“‘
The main requirement is the login password error three times, no login
Designed as follows
1, first define a user name and password
2, define a blacklist, used to store more than three times the user name
3, gets the user's input user name
4, first determine whether the user is blacklisted, if there is, prompt has, and unconditional exit
5, if not in the blacklist, will be three times the password check
Author Qi qi Dad
’”
# The definition string must be double-quoted
Real_name= "Czb"
real_pwd=123456
# If the read-write mode is r, you need to create a document to create a blacklist document as follows VI Heimingdan.txt, if not created, will be prompted not to find the file, cannot open
F=open ("Heimingdan.txt". R ')
#将黑名单中的结果一次性的读入
Result=f.read ()
F.close ()
#raw_input and input are the usages of python2.7 and Python3 respectively, note the difference
Usename=raw_input ("Please enter user name")
For I in range (1):
If Usename==result:
Print ("You have entered the blacklist and cannot log in")
Exit ()
Else
Continue
Usepwd=raw_input ("Please enter password")
For I in range (3):
If real_pwd==usepwd:
Print ("Login Successful")
Break
Else
Print ("Bad password")
Count +=1
If Count ==3:
Print ("Password error more than three times, no login")
F=open ("Heimingdan.txt", ' W ')
F.write (Usename)
F.close ()
Python Login three Forbidden Login