I thought it might look like this but I am unsure:
example = open("example.txt","r")
if example #has text1 in it then#: <-- What do I need to put between the #'s for the code to work?
import re
wordChk = re.compile(r'(.*)?text1(.*)?')
fileName=open("d:/foo.bar")
lines = [i for i in fileName.readlines()]
for x in lines:
if wordChk.match(x):
do something
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.