dark_shadow
dark_shadow

Reputation: 3573

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)

Upvotes: 0

Views: 3144

Answers (1)

wim
wim

Reputation: 363476

>>> "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'

Upvotes: 1

Related Questions