[英]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. 我在使用
"abcd%s"%(e)
类的参数创建字符串时遇到此错误,但通过抓取网页获取e。 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. 我发现了其他类似的问题,但是他们在URL中使用了
%20
,因此需要用%%20
替换%20
%%20
来解决问题。 But my case is different. 但是我的情况不同。 I tried encoding e but still getting same error.
我尝试编码e,但仍然收到相同的错误。
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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.