i trying write multiple matches regex file on single line way.
matches = re.findall(<form>(.*?)</form>, line, re.dotall) form in matches: form = ("'" + form + "', ") f = open(new_file, 'a+') f.write(form.rstrip('\n'), ) the above gives me this:
'form1', 'form2',....,'formn', how can have them enclosed in parentheses , no comma @ end below?
('form1', 'form2',....,'formn') thanks much.
something this?
matches = re.findall(<form>(.*?)</form>, line, re.dotall) if matches: f = open(new_file, 'a+') f.write("('%s')" % "', '".join(matches)) f.close()
Comments
Post a Comment