无法在python IDE中输入unicode(Mac OS X)

fro*_*uds 6 python ide unicode macos utf-8

我正在尝试在默认的python IDE中收集一些unicode raw_input,据我所知,它应该像下面这样简单:

>>> c = raw_input()
???
>>> print c
???
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试输入unicode字符时,计算机会发出一些声音,最后会出现一个空字符串.(为此,我在时间点击IME切换器并选择适当的输入方法[在本例中为日语输入].在python IDE之外,输入工作正常,我可以输入字符,系统将它们识别为已输入.在IDE中,我会输入一些平假名,并且下拉汉字选择窗口像往常一样出现,但是当我选择适当的表示并按下回车时,那些哔哔声会响起来,我什么都没有.我觉得我错过了一个涉及某处的环境.

版本是:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Run Code Online (Sandbox Code Playgroud)

Python 2.5.4 (r254:67916, Jun 24 2010, 21:47:25) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Run Code Online (Sandbox Code Playgroud)

两者都不起作用.还有这个:

>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>> sys.stdin.encoding
'UTF-8'
>>> sys.stdout.encoding
'UTF-8'
>>> sys.getfilesystemencoding()
'utf-8'
Run Code Online (Sandbox Code Playgroud)

但从我所读到的,违约编码是一个神秘的野兽.改变它实际上并没有解决任何问题.那是,

>>> import sys
>>> sys.setdefaultencoding('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>> reload(sys)
<module 'sys' (built-in)>
>>> sys.setdefaultencoding('utf-8')
>>> # !!!
... c = raw_input()
no dice!
Run Code Online (Sandbox Code Playgroud)

不起作用.更多的哔哔声.我也不能从其他应用程序中剪切和粘贴日文文本.

Chr*_*egg 0

编辑:我从命令行(终端)尝试了Python,但它不起作用,并且我听到了你所说的蜂鸣声。这似乎不是终端限制,因为我可以在提示符下粘贴$字符bash。它在空闲状态下确实有效,如下所示。

\n\n

编辑#2:有趣的是,这句话确实有效:

\n\n
 $ python -c "exec(\\"c=raw_input()\\nprint c\\")"\n \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e  <-- pasted\n \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e\n
Run Code Online (Sandbox Code Playgroud)\n\n

我会把它放在评论中,但它的格式不正确。MacOSX 上 2.6.5 的输出:

\n\n
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) \n[GCC 4.0.1 (Apple Inc. build 5493)] on darwin\nType "copyright", "credits" or "license()" for more information.\n\n    ****************************************************************\n    Personal firewall software may warn about the connection IDLE\n    makes to its subprocess using this computer\'s internal loopback\n    interface.  This connection is not visible on any external\n    interface and no data is sent to or received from the Internet.\n    ****************************************************************\n\nIDLE 2.6.5      \n>>> c=raw_input()\n\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e\n>>> print c\n\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e\n>>> c\nu\'\\u65e5\\u672c\\u8a9e\'\n>>> \n
Run Code Online (Sandbox Code Playgroud)\n