How to find a specific string in a .txt file Python -
i have large textfile on computer (location: /home/seth/documents/bruteforce/passwords.txt) , i'm trying find specific string in file. list has 1 word per line , 215,000 lines/words. know of simple python script can use find specific string?
here's code have far,
f = open("home/seth/documents/bruteforce/passwords.txt", "r") line in f.readlines(): line = str(line.lower()) print str(line) if str(line) == "abe": print "success!" else: print str(line)
i keep running script, never finds word in file (and know sure word in file).
is there wrong code? there simpler method 1 i'm trying use?
your appreciated.
ps: i'm using python 2.7 on debian linux laptop.
it's because forgot strip new line char @ end of each line.
line = line.strip().lower()
would help.
Comments
Post a Comment