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