在Eclipse Pydev控制台和Idle中打印Unicode
发布于 2021-01-29 18:24:28
我的配置:Win7 + Python 2.6 + eclipse + PyDev
如何在以下位置启用Unicode打印语句:
- Eclipse中的PyDev控制台
- 空闲的Python GUI
打印语句示例:
print(u"שלום עולם")
结果如下:
ùìåí òåìí
关注者
0
被浏览
50
1 个回答
-
对于Eclipse Unicode控制台支持:
- 添加
-Dfile.encoding=UTF-8
到eclipse.ini
eclipse安装目录中。 - 在日食中-
Run\Run Configurations\Python Run\configuration\Common\
确保选择UTF-8 - 在日食中-
Window\Preferences\General\Workspace\Text file encoding\
确保选择了UTF-8 - 从
[python install path]\Lib\site.py
-更改encoding = "ascii"
为encoding = "utf-8"
- 确保您在Eclipse中使用支持Unicode的字体-
Window\Preferences\Appearance\Colors and Fonts\Debug\Console font\Edit
在安装中,我完成了以上所有操作:
print(u"שלום עולם") # Doesn't work print("שלום עולם") # Works
对于Django模型:
print(my_model.my_field) # Doesn't work print(my_model.my_field.encode('utf-8')) # Works
- 添加