简体   繁体   English

UnicodeEncodeError:'charmap'编解码器无法编码字符

[英]UnicodeEncodeError: 'charmap' codec can't encode character

Python throws this when using the wolfram alpha api: 使用wolfram alpha api时,Python会抛出这个:

Traceback (most recent call last):
  File "c:\Python27\lib\threading.py", line 530, in __bootstrap_inner
    self.run()
  File "c:\Python27\lib\site-packages\Skype4Py\utils.py", line 225, in run
    handler(*self.args, **self.kwargs)
  File "s.py", line 38, in OnMessageStatus
    if body[0:5] == '!math':wolfram(body[5:], '')
  File "s.py", line 18, in wolfram
    print "l: "+l
  File "c:\Python27\lib\encodings\cp437.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\xd7' in position 3
: character maps to <undefined>

how can I solve this? 我该怎么解决这个问题?

Looks like you're passing in high-byte data to the API, and it's not liking that (\\xd7 is the "Times" character; looks like an X). 看起来你正在将高字节数据传递给API,并且它不喜欢(\\ xd7是“Times”字符;看起来像X)。 I'm not certain what purpose the print is for, but changing it to be print "l: " + repr(l) or print "l: ", l might at least get you past the above error, assuming you don't want to be in the business of converting the body to unicode (I'm assuming it's not...). 我不确定打印的目的是什么,但将其更改为print "l: " + repr(l)print "l: ", l可能至少会让您超过上述错误,假设您没有我希望从事身体转换为unicode(我假设它不是......)。

If that doesn't help, we'll need more details. 如果这没有帮助,我们需要更多细节。 Where is your input coming from? 你的意见来自哪里? Is body unicode, or a byte string? 是身体unicode,还是字节串? Are you using python 2.7 or 3.x? 你在使用python 2.7或3.x吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UnicodeEncodeError: &#39;charmap&#39; 编解码器无法编码字符:字符映射到<undefined> - UnicodeEncodeError: 'charmap' codec can't encode character : character maps to <undefined> UnicodeEncodeError:&#39;charmap&#39;编解码器无法对字符字符映射进行编码<undefined> - UnicodeEncodeError: 'charmap' codec can't encode character character maps to <undefined> Pandas UnicodeEncodeError: &#39;charmap&#39; 编解码器无法编码字符 - Pandas UnicodeEncodeError: 'charmap' codec can't encode character MongoDB中的Python错误“ UnicodeEncodeError:&#39;charmap&#39;编解码器无法编码字符” - Python error “UnicodeEncodeError: 'charmap' codec can't encode character” in MongoDB UnicodeEncodeError:&#39;charmap&#39;编解码器无法编码字符...问题 - UnicodeEncodeError: 'charmap' codec can't encode character… problems UnicodeEncodeError:&#39;charmap&#39;编解码器无法编码字符&#39;\\ u2264&#39; - UnicodeEncodeError: 'charmap' codec can't encode character '\u2264' UnicodeEncodeError: 'charmap' 编解码器无法编码字符 - UnicodeEncodeError: 'charmap' codec can't encode characters 字符编码错误:UnicodeEncodeError:&#39;charmap&#39;编解码器无法对位置Y中的字符X进行编码:字符映射到<undefined> - Character encoding error: UnicodeEncodeError: 'charmap' codec can't encode character X in position Y: character maps to <undefined> Python 3-UnicodeEncodeError:“ charmap”编解码器无法编码字符(编码后在文件中) - python 3 - UnicodeEncodeError: 'charmap' codec can't encode character (Encode so it's in a file) UnicodeEncodeError:&#39;charmap&#39;编解码器无法对位置0中的字符&#39;\\ x80&#39;进行编码:字符映射到<undefined> - UnicodeEncodeError : 'charmap' codec can't encode character '\x80' in position 0 : character maps to <undefined>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM