Reputation: 3573
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
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