Python Login Interface

Source: Internet
Author: User

#!/usr/bin/env python
Import Sys
Name =‘‘
pw=‘‘
Name_num =0
Pw_num =0
#black_list = []
WithOpen' A.txt ',' R ')As F:
For IIn F.xreadlines ():
Namelist.append (I.split () [0])
Pwlist.append (I.split () [1])

DefName_test (input_name, NameList):
If Input_nameIn NameList:
ReturnTrue
Else
ReturnFalse

Name =Raw_input (' Please input your name: ')
Name_num + =1
WhileTrue:
If Name_test (name, NameList):
Break
Else
If Name_num <3:
Name =Raw_input (' Name is error,please input your Name again: ')
Name_num + =1
Else
Print' Sorry,today you have mistyped user name three times '
Sys.exit ()

PW =Raw_input (' Please input your password: ')
Pw_num + =1
WhileTrue:
INDEX_PW = Pwlist[namelist.index (name)]
if pw = index_pw:
Print ' welcome '
break
else:
If Pw_num < PW = raw_input (" PASSWD is Error,please input your passwd again: ')
Pw_num +=1
else:
print Sorry,today you had to lose the wrong password three times '
Bao 123
Zhang 456

Some small programs that will be blacklisted later < Span style= "color: #cc7832; Font-weight:bold; " >

There is a program that my friend gave me, feel his more concise, look comfortable:
#!/usr/bin/env python
#-*-Coding:utf-8-*-
# @Time: 2016/7/29 11:46
# @Author: Big_bao
Import Sys
DefName_test (input_name, NameList):
If Input_nameIn NameList:
ReturnTrue
Else
Print' Name is None. '
ReturnFalse

DefPw_test (PW, INDEX_PW, innerloopnumber=0):
If pw = = INDEX_PW:
Print' Welcome. '
inn = innerloopnumber+1
Return Inn
Else
Print' Password is None. '

NameList = []
Pwlist = []
WithOpen' A.txt ',' R ')As F:
For IIn F.xreadlines ():
Namelist.append (I.split () [0])
Pwlist.append (I.split () [1])

INDEX_PW = []
Name =‘‘
pw=‘‘
Name_num =0
Pw_num =0
Inloopnum =0

Name =Raw_input (' Please input your name: ')
Name_num + =1
WhileTrue:
If Name_test (name, NameList):
INDEX_PW = Pwlist[namelist.index (name)]
PW =Raw_input (' Please input your password: ')
Pw_num + =1
Inloopnum_ = Pw_test (pw, INDEX_PW,Innerloopnumber=inloopnum)
Else
Name =Raw_input (' Please input your name again: ')
Name_num + =1

if name_num == 3:
print sys.exit ()
if Pw_num== print ' You have no chance '
sys.exit (
if Inloopnum_== 1:
sys.exit ()

< Span style= "color: #cc7832; Font-weight:bold; " > Thank the friend who is far away in Chengdu Usual pointers


Python Login Interface

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.