First of all, programming to search for a character string in a text file with python. The reason I made it is because I often write sentences, so it was necessary to check prohibited characters.
If you hit the command prompt as above ...
Discover if the string "python" in pythontest.txt exists! Is displayed.
Contents of txt
pythontest.txt
Python pison paison puison poison peison poson
Below is the source.
stringParser.py
import sys
argvs = sys.argv
try:
f = open(argvs[1],'r')
for row in f:
if row.find("Python") > -1:
print("Discover! !!")
else:
print("Not found")
f.close()
except:
print("File not found")
It's like that. Command line arguments are basic for the time being, so I have to be able to use them!