Python3 's Landing

Source: Internet
Author: User

Requirements:

1, can see the detection login name and password,

2. Password input error 3 times, lock the login name to death

# Author:jujue
Import time

Username_list=[]
Password_list=[]
Username_lock_list=[]
#创建登录名的. txt text
F_username=open (' Login_username.txt ', ' w+ ')
F_username.write (' Sumeng,yixin,jujue ')
F_username=open (' Login_username.txt ', ' R ')
#读取 the contents of the. txt text, stored in a string
For line in F_username:
User=line
#关闭文本, freeing up resources
F_username.close ()
#建立密码. txt text
F_password=open (' Login_password.txt ', ' w+ ')
F_password.write (' 123456,abcabc,abc123 ')
#读取 the contents of the. txt text, stored in a string
F_password=open (' Login_password.txt ', ' R ')
For line in F_password:
Passwd=line
#释放资源
F_password.close ()
#将字符串转换成列表, implementing the STR conversion list
Username_list=user.strip (', '). Split (', ')
Password_list=passwd.strip (', '). Split (', ')
#c创建锁定文本
F_login_username_lock=open (' Login_username_lock.txt ', ' A + ')
F_login_username_lock=open (' Login_username_lock.txt ', ' R ')
For line in F_login_username_lock:
#判断文本内容是否为空, is empty
If Line.strip () = = ": #为空
username_lock_list=line# Empty list
Else
#不为空 to read the text contents of the string
Username_lock=line
# Convert a string to a list to implement the STR convert list
Username_lock_list = Username_lock.strip (', '). Split (', ')
#释放内存
F_login_username_lock.close ()

#创建保存输入次数错误三次的登录名, to lock the login name
Print (' Please input username and password...\n ')
Count=0
#输入登录名和密码
Username = input (' username: ')
Password = input (' Password: ')
#检测登录名是否在锁定文本内
If username in username_lock_list: #在
Print (' Landing ... ')
Time.sleep (1) #等1s
Print (' This login name is locked due to too many output password errors ... ', username)
#登录名不在锁定文本内
Else
While Count <3:
#登录名是否在允许登陆的文本内, in:
If username in username_list:
#确定登录名对应密码在字符串中的位置
Username_position = Username_list.index (username)
#判断输入密码是否和登录名对应的密码一致, consistent with the success of this landing site
If password_list[username_position] = = Password:
Print (' Landing ... ')
Time.sleep (1)
Print (' Login successful!!! ‘)
Break
#密码错误
Else
Print (' Landing ... ')
Time.sleep (1)
Print (' Login failed ... Input password is wrong, please re-enter the password ... ')
Password = input (' Password: ')
Count+=1
#当密码输入错误三次时
if Count = = 3:
Print (' Input password error too many times ... ')
#将登录名写入锁定登录名的文本中死锁登录名
F_login_username_lock = open (' Login_username_lock.txt ', ' A + ')
F_login_username_lock.write (username)
F_login_username_lock.write (', ')
F_login_username_lock.close ()
#登录名输入错误, re-enter
Else
Print (' Landing ... ')
Time.sleep (1)
Print (' Enter login name or password Error!!! Please re-enter ... ')
Username = input (' username: ')
Password = input (' Password: ')

Python3 's Landing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.