简体   繁体   中英

ValueError: unsupported format character 'C' (0x43)

I'm getting this error on creating a string with arguments like "abcd%s"%(e) but I'm getting e by scraping a web page. Can anyone please tell me what is the best way to avoid this error.

I found other similar questions but they were using %20 in the url for which they need to replace %20 with %%20 which solved their problem. But my case is different. I tried encoding e but still getting same error.

ValueError: unsupported format character 'W' (0x57)
>>> "abcd%W"%(123)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unsupported format character 'W' (0x57) at index 5

Could something like this work for you instead?

>>> "abcd%W".replace('%W', str(123))
'abcd123'

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