Oct-27-2017, 03:50 PM
(Oct-27-2017, 03:48 PM)heiner55 Wrote: Then remove sep=''':
print("Line ", linenr, ": ", match[1])
I tried doing this earlier but received the following :
>>> with open ('phone_log.txt') as in_file:
for linenr, line in enumerate(in_file):
match = re.search(pattern, line, re.X)
if match:
print("Line ", linenr, ": ", match[1])
Traceback (most recent call last):
File "<pyshell#20>", line 3, in <module>
match = re.search(pattern, line, re.X)
File "C:\Python27\lib\re.py", line 142, in search
return _compile(pattern, flags).search(string)
File "C:\Python27\lib\re.py", line 235, in _compile
raise ValueError('Cannot process flags argument with a compiled pattern')
ValueError: Cannot process flags argument with a compiled pattern