python - How can I fix that line re.sub -


i want pass variable re.sub there error , can't figure out how fix it?

preset_name = "preset " data = re.sub("name=\"%s[^]]*/select", lambda x:x.group(0).replace('selected',''), html) % preset_name 

here error:

typeerror: not arguments converted during string formatting

data =re.sub("name=\"%s[^]]*/select" % preset_name, lambda x:x.group(0).replace('selected',''), html) 

% operates on string


Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -