Python Login three Forbidden Login

Source: Internet
Author: User

#! /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

Related Article

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.