[英]`ascii‘ codec can’t enforce character u’\u2022‘ in position 206:
I get this error when I try to execute my python script on my Ubuntu 20.4 homeserver:当我尝试在我的 Ubuntu 20.4 主服务器上执行我的 python 脚本时出现此错误:
`ascii' codec can't enforce character u'\•' in position 206: ordinal not in range (128) 'ascii' 编解码器无法在位置 206 中强制执行字符 u'\•':序数不在范围内(128)
You should read the Python Unicode HOWTO .你应该阅读 Python Unicode HOWTO 。 This error is thefirst example .
这个错误是第一个例子。
Basically, you shouldn't str
to convert from Unicode to encoded text/bytes.基本上,您不应该
str
从 Unicode 转换为编码的文本/字节。
Instead, use .encode()
to encode the string:相反,使用
.encode()
对字符串进行编码:
text = 'some_str'.encode('utf-8').strip()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.