Each line an element in an array when reading text file in Python
This question already has an answer here:
import io
data = []
with io.open('MasterList.txt', encoding='latin-1') as myfile:
for i in myfile.readlines():
data.append(i)
Then you can loop data
and compare it with the entered password
. You can use:
if password in data:
print "Password found in data"
链接地址: http://www.djcxy.com/p/42350.html
上一篇: Python:将每行单词放入列表中