Python learns the first week of homework

Source: Internet
Author: User

#! /usr/bin/env python
#-*-Coding:utf-8-*-
# @Author: Yue Qian
# @date: 2018-03-04
"""
Requirements: Enter user name, password, authentication successful display welcome information, enter the error three times after locking the user.

Process:
1. Determine if the user is blacklisted, if the blacklist prompts the account lock.

2. Determine if the user exists, if there is no prompt account does not exist.

3. Determine if the account password is correct, if you log in correctly. If the password is not correctly three times, enter the opportunity. Three times all wrong, account locked.
"""

Count =0#用户的循环次数
Username ="Python"
Password ="123"

WithOpen"Lock_file.txt")As F:#打开黑名单
file_l = F.readlines ()The method of #使用. ReadLines () reads the blacklist file row by line and assigns a value to the user_list variable
Name =Input"Username:")

# Determine if the input user name is in the blacklist
If nameIn file_l:# If the username is within the blacklist
Print"Sorry,you account is locked." Please contact administrator! ")
Else

# Determine if the user name exists
If name = = Username:#使用if判断用户输入的用户是否在
While Count <3:
Password =Input"Password:")
if password = = password:
Print"Welcome%s Login System"% name)#用户名正确, the password is correct
Break
Else
Print"Password is error!")#用户名正确, bad password
Count + =1 #用户名正确, password error, continue looping
else:

# three times All wrong, account locked
print ( with open ( "Lock_ File.txt ") as f:
Test = ("%s "% name) #错误用户名

else:
print ( "User name does not exist, please input again! ")

Python to learn the first week of work

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.