Python uses a list to make a simple login

Source: Internet
Author: User

650) this.width=650; "title=" pythonlist.jpg "src=" http://s2.51cto.com/wyfs02/M02/7A/E3/ Wkiol1bbkmzhw8llaaojcnigmzu292.jpg "alt=" Wkiol1bbkmzhw8llaaojcnigmzu292.jpg "/>

http://bbs.51cto.com/viewthread.php?tid=1318046 This is the original post

#!/usr/bin/env python
#-*-Coding:utf-8-*-


file_obj = File (' D:\Python\TEST1.txt ', ' r+ ') #打开TEST1. txt This document is in the r+ way
L = [] #定义一个空list
Obj_list=file_obj.readlines () #读取TEST1. txt multiple lines I wrote two lines.

For Ele in Obj_list:
Line= Ele.strip () #去掉每个字符的空格
V =line.split (") #以空格分割每个字符
L.extend (v) #将每个元素添加进L列表 here Note if the append is added to the list
Print L
Conter = 0
Import Getpass

While True:
If Conter < 3:
account = raw_input (' Please input your username: ')
If account in L:
Print "Welcome loading"
Break
Else
print ' loading error, please again: '
Conter +=1
Continue
Else
Break
While True:
If Conter < 5:
passwd = Getpass.getpass (' Please input password: ') #这里密码不是显示的
If Len (passwd) ==0 or passwd! = '[email protected]‘:
Print "Password Error"
Conter +=1
Continue
Else
print "Loading Complet"
Break
Else
Print "byebye!"
Break

Python uses a list to make a simple 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.