简体   繁体   English

ValueError:不支持的格式字符'C'(0x43)

[英]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.

相关问题 ValueError:索引3处不支持的格式字符&#39;&lt;&#39;(0x3c) - ValueError: unsupported format character '<' (0x3c) at index 3 ValueError: 不支持的格式字符 ']' (0x5d) - ValueError: unsupported format character ']' (0x5d) ValueError:不支持的格式字符&#39; - ValueError: unsupported format character ' 格式化字符串时出错-ValueError:不支持的格式字符&#39;,&#39;(0x2c) - Error when formatting a String - ValueError: unsupported format character ',' (0x2c) Python,Django:ValueError:索引3处不受支持的格式字符&#39;(&#39;(0x28) - Python, Django: ValueError: unsupported format character '(' (0x28) at index 3 ValueError:索引79处不支持的格式字符&#39;a&#39;(0x61) - ValueError: unsupported format character 'a' (0x61) at index 79 ValueError:定义字典中不支持的格式字符'{'(0x7b) - ValueError: unsupported format character '{' (0x7b) in defining dictionary Python:ValueError:索引1处不支持的格式字符&#39;&#39;&#39;(0x27) - Python: ValueError: unsupported format character ''' (0x27) at index 1 ValueError:索引 650 处不支持的格式字符 &#39;w&#39; (0x77) - ValueError: unsupported format character 'w' (0x77) at index 650 ValueError:索引处不支持的格式字符&#39;{&#39;(0x7b) - ValueError: unsupported format character '{' (0x7b) at index
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM