如果我尝试粘贴一个unicode字符,如中间点:
·
在我的python解释器中它什么都不做.我在Mac OS X上使用Terminal.app,当我只是在bash中我没有遇到麻烦:
:~$ ·
Run Code Online (Sandbox Code Playgroud)
但在翻译中:
:~$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Code Online (Sandbox Code Playgroud)
^^我什么都没得到,它只是忽略了我只是粘贴了这个角色.如果我使用中间点'\ xc2\xb7'的escape\xNN\xNN表示,并尝试转换为unicode,尝试显示点会导致解释器抛出错误:
>>> unicode('\xc2\xb7')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)
我在sitecustomize.py中设置了'utf-8'作为我的默认编码,所以:
>>> sys.getdefaultencoding()
'utf-8'
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?这不是终点站.这不是Python,我做错了什么?!