UnicodeEncodeError:“charmap”编解码器无法将字符字符映射编码到<undefined>

2024-10-02 20:34:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用unicode写入文件时遇到问题。我使用的是python2.7.3。它给了我这样一个错误:

UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' in position 1006: character maps to <undefined>

下面是我的代码示例:error is on line:f3.write(text)

^{pr2}$

我也试过使用'utf-8'和'utf-8-sig',但是没有用。我的源文件中有这样的符号可以读取:['\”,;?*&;$#@%]和不同语言的符号。 我如何解决这个问题?请帮忙,我先看了stackoverflow上的信息,但没用。在


Tags: 文件in错误unicode符号positioncanutf