Created
February 19, 2018 14:16
-
-
Save nake89/2d26835f0f3985e169b3c1464b204761 to your computer and use it in GitHub Desktop.
searchinfile python function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def searchinfile(srchstr, filename): | |
with open(filename) as f: | |
wasd = 0 | |
for line in f: | |
#print(line.lower(), end='') | |
tolwr = line.lower() | |
if srchstr in tolwr: | |
#print("found test in: " + line) | |
wasd += 1 | |
print("Found " + str(wasd)+ " amount of " + srchstr + " in " + filename) | |
filezzz = "multiline.txt" | |
searchinfile("vege" ,filezzz) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment