免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9754 | 回复: 6
打印 上一主题 下一主题

pydev在eclipse里面的输出,怎么显示中文? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-09 10:14 |只看该作者 |倒序浏览
#!/usr/bin/python
# -*- coding: utf-8 -*-
print "中文"

输出
涓?枃

论坛徽章:
0
2 [报告]
发表于 2006-03-09 12:16 |只看该作者
改成
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. print u"中文"
复制代码


直接在命令行窗口下执行可以,在pydev中run就不行
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

pydev创建的文件编码是utf-8

[ 本帖最后由 wolfg 于 2006-3-9 12:17 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2006-03-09 13:15 |只看该作者
自己看了一下帮助。。

eclipse console default的encoding是GBK,
写成

  1. #!/usr/bin/python
  2. # -*- coding: GBK -*-
  3. print "中文"
复制代码

就可以,
如果写成

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. print "中文"
复制代码

需要设置console的encoding为utf-8

方法
Console encoding
The console can be configured to display output using a character encoding different from the default encoding. To set the console encoding for an application, use the Console Encoding settings on the Common tab of a launch configuration.

论坛徽章:
0
4 [报告]
发表于 2006-03-09 21:56 |只看该作者
字符集问题啊,,,烦!!!!!!!!!

论坛徽章:
0
5 [报告]
发表于 2006-10-20 21:13 |只看该作者
我把console改称utf-8还是不行,晕阿

论坛徽章:
0
6 [报告]
发表于 2006-10-20 21:56 |只看该作者
我在windows下一般都设置成 cp936

论坛徽章:
0
7 [报告]
发表于 2008-07-29 23:24 |只看该作者
pyshell和pycrust是不是不支持中文输入?
我只好用sctie
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP