I have a file contains lines like:
754.82915: MODE1(0, 0x001900, 0x00090)
754.82916: MODE2(0, 0x001900, 0x00090)
How to take the data from "(" to ")" in python??.
I tried the code:
fo=open("file1.txt","r")
fin=open("file2.txt","w")
lines=fo.readlines()
for line in lines:
result=re.search(r'\(.*\)', line)
res="\n"+result.group()
fin.write(res)
fo.close()
It showing following error:
AttributeError: 'NoneType' object has no attribute 'group'
re.search(pattern, string, flags=0): Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string.