Eclipse控制台和Python中的编码问题 [英] Problems with Encoding in Eclipse Console and Python
问题描述
那么,如何实现,那在Eclipse控制台中的输出可以显示äöü等。
我尝试过:
在第一行声明文档编码与
# - * - 编码:utf-8 - * -
我将Window / Preferences / General / Workspace和Project / Properties中的编码设置更改为UTF-8
由于没有更改尝试以下的事情单独和组合,但没有什么似乎工作:
-
更改stdout如Python Cookbook中所述:
sys.stdout = codecs.lookup(utf-8) - 1
-
添加unicode u:
打印uäöü.encode('UTF8')
- 重新加载系统(我不知道是什么,但它不起作用; - ))
我a我试图这样做,以调试编码问题我在我的程序...(argh)
任何想法?感谢提前!
编辑:
我在Windows 7上工作,它是EasyEclipse
得到了!如果您有同样的问题,请转到
运行/运行配置/常用
并选择UTF-8 )作为控制台编码。
所以,最后,打印ö
导致 ö
I guess I need some help regarding encodings in Python (2.6) and Eclipse. I used Google and the so-search and tried a lot of things but as a matter of fact I don't get it.
So, how do I achieve, that the output in the Eclipse console is able to show äöü etc.?
I tried: Declaring the document encoding in the first line with
# -*- coding: utf-8 -*-
I changed the encoding settings in Window/Preferences/General/Workspace and Project/Properties to UTF-8
As nothing changed I tried the following things alone and in combination but nothing seemed to work out:
Changing the stdout as mentioned in the Python Cookbook:
sys.stdout = codecs.lookup("utf-8")-1
Adding an unicode u:
print u"äöü".encode('UTF8')
- reloading sys (I don't know what for but it doesn't work either ;-))
I am trying to do this in order to debug the encoding-problems I have in my programs... (argh)
Any ideas? Thanks in advance!
EDIT: I work on Windows 7 and it is EasyEclipse
Got it! If you have the same problem go to
Run/Run Configurations/Common
and select the UTF-8 (e.g.) as console encoding.
So, finally, print "ö"
results in "ö"
这篇关于Eclipse控制台和Python中的编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!