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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -