hi,
please help me to solve the error for:
text1.txt:
line1 <data>
line2 <items>
line3 <match name="item1" rhs="domain.com"></match>
line4 <match name="item2" rhs="domainn.com"></match>
line5 <match name="item2" rhs="1010data.com"></match>
line6 </items>
line7 </data>
text2.txt:
line1 djshjsdf
line2 sdfngjfg
check domain.com,domain.com,1010data.com in text2.com, if not there print domain.com,domain.com,1010data.com in to the 3rd text file(text3.txt)
import re
with open('C:\\Users\\Desktop\\m\\test1.txt', 'r') as f_in:
with open('C:\\Users\\Desktop\\m\\test_compare.txt', 'r') as f_compare:
with open('C:\\Users\\Desktop\\m\\result.txt', 'w') as f_out:
d1 = f_in.read()
d2 = f_compare.read()
for match in re.finditer(r'rhs="(.*)"', d1):
if match not in d2:
f_out.write('{}\n'.format(match.group(1)))
while running the above code, it throws an error
Traceback (most recent call last):
File "C:\Python27\comparetwofiles\src\compare\notepadtest.py", line 11, in <module>
if match not in d2:
TypeError: 'in <string>' requires string as left operand, not _sre.SRE_Match
can anyone help me to fix the above error.....