#!/usr/bin/python
# -*- coding: utf-8 -*-
print "中文"
输出
涓枃
wolfg 回复于:2006-03-09 12:16:27
改成
#!/usr/bin/python
# -*- coding: utf-8 -*-
print u"中文"
直接在命令行窗口下执行可以,在pydev中run就不行
[color=#FF0000]UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)[/color]
pydev创建的文件编码是utf-8
[ 本帖最后由 wolfg 于 2006-3-9 12:17 编辑 ]
phpbird 回复于:2006-03-09 13:15:16
自己看了一下帮助。。
:oops:
eclipse console default的encoding是GBK,
写成
#!/usr/bin/python
# -*- coding: GBK -*-
print "中文"
就可以,
如果写成
#!/usr/bin/python
# -*- coding: utf-8 -*-
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.
xiaohu0 回复于:2006-03-09 21:56:02
字符集问题啊,,,烦!!!!!!!!!
xinye0123 回复于:2006-10-20 21:13:46
我把console改称utf-8还是不行,晕阿
MichaelBibby 回复于:2006-10-20 21:56:36
我在windows下一般都设置成 cp936
|