简体   繁体   中英

unsupported format character ''' (0x27) at index while passing parameter as well as using wildcard in query

i am facing an issue in python where i am using a query and i am passing some params in it:

query =   select * from %s where xyz like 'abc%'
  query %(tablename)

here it gives me an error. Can anyone help in this

It looks like python is interpreting the % as a printf-like format character. Try using %%?

query =   select * from %s where xyz like 'abc%%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM