简体   繁体   English

实现RenderTree函数时python 3.5 conda中的Unicode错误

[英]Unicode error in python 3.5 conda while implementing RenderTree function

I am using anytree package for creating tree. 我正在使用anytree包来创建树。

udo = Node("Udo")
marc = Node("Marc", parent=udo)
print(RenderTree(udo))

While using RenderTree function, I am getting unicode error as below: 使用RenderTree函数时,出现unicode错误,如下所示:

Traceback (most recent call last): File "C:\\Users\\Neelakshi\\workspace\\LogisticRegression\\TypeHierarchyTest.py", line 16, in print(RenderTree(udo)) File "C:\\Miniconda3\\envs\\Python35\\lib\\encodings\\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 14-16: character maps to 追溯(最近一次通话):文件“ C:\\ Users \\ Neelakshi \\ workspace \\ LogisticRegression \\ TypeHierarchyTest.py”,行16,在print(RenderTree(udo))中,文件“ C:\\ Miniconda3 \\ envs \\ Python35 \\ lib \\编码返回codecs.charmap_encode(input,self.errors,encoding_table)[0]中的encodings \\ cp1252.py“,第19行,[0] UnicodeEncodeError:“ charmap”编解码器无法对位置14-16中的字符进行编码:字符映射到

I have seen similar threads for this issue but could not find solution for it. 我已经看到类似的线程来解决此问题,但是找不到解决方案。 I am running this sample program from eclipse and not from command line. 我正在从eclipse运行此示例程序,而不是从命令行运行。 Following are package details : 以下是包装的详细信息:

python: 3.5.1
conda: 4.3.24

I resolved this issue by changing Eclipse encoding settings to Utf-8. 我通过将Eclipse编码设置更改为Utf-8解决了此问题。 It was cp1252 before. 以前是cp1252。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM