Printing Unicode in eclipse Pydev console and in Idle(在 Eclipse Pydev 控制台和 Idle 中打印 Unicode)
问题描述
我的配置:Win7 + Python 2.6 + eclipse + PyDev
My configuration: Win7 + Python 2.6 + eclipse + PyDev
如何在以下位置启用 Unicode 打印语句:
How do I enable Unicode print statements in:
- Eclipse 中的 PyDev 控制台
 - 空闲 Python GUI
 
打印语句示例:
print(u"שלום עולם")
结果如下:
ùìåí òåìí
推荐答案
对于 eclipse unicode 控制台支持:
For eclipse unicode console support:
- 将 
-Dfile.encoding=UTF-8添加到 eclipse 安装目录中的eclipse.ini中. - 在 Eclipse 中 - 
RunRun ConfigurationsPython RunconfigurationCommon确保选择了 UTF-8 - 在 Eclipse 中 - 
WindowPreferencesGeneralWorkspaceText 文件编码确保选择了 UTF-8 - 在 
[python 安装路径]Libsite.py- 从encoding = "ascii"更改为encoding = "utf-8"代码> - 确保您在 Eclipse 中使用支持 unicode 的字体 - 
WindowPreferencesAppearanceColors and FontsDebugConsole fontEdit 
- Add 
-Dfile.encoding=UTF-8toeclipse.iniwhich is in the eclipse install directory. - In eclipse - 
RunRun ConfigurationsPython RunconfigurationCommonmake sure UTF-8 is selected - In eclipse - 
WindowPreferencesGeneralWorkspaceText file encodingmaking sure UTF-8 is selected - In 
[python install path]Libsite.py- change fromencoding = "ascii"toencoding = "utf-8" - Make sure you're using unicode supporting fonts in eclipse - 
WindowPreferencesAppearanceColors and FontsDebugConsole fontEdit 
在安装过程中,我完成了上述所有操作:
In the installation I did all of the above:
print(u"שלום עולם")         # Doesn't work
print("שלום עולם")          # Works
对于 django 模型:
For django models:
print(my_model.my_field)                 # Doesn't work
print(my_model.my_field.encode('utf-8')) # Works
                        这篇关于在 Eclipse Pydev 控制台和 Idle 中打印 Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Eclipse Pydev 控制台和 Idle 中打印 Unicode
				
        
 
            
        - 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
 - 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
 - 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
 - 未找到/usr/local/lib 中的库 2022-01-01
 - GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
 - 如何指定 CORS 的响应标头? 2022-01-01
 - java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
 - Eclipse 的最佳 XML 编辑器 2022-01-01
 - 获取数字的最后一位 2022-01-01
 - 转换 ldap 日期 2022-01-01
 
						
						
						
						
						
				
				
				
				