因此,在python终端中,我键入以下内容:>>> s = "γειά" ## it just means 'hi' in Greek
>>> s
'\x9a\x9c\xa0\xe1' ## What is this? - Is it utf-encoding? Is it ascii escaped?
>>> print s
γειά
现在有趣的是:
^{pr2}$
我对编码非常困惑,尤其是utf-8编码的字符串和/或ascii编码的字符串。以上两个代码段之间的区别是什么?它们是如何绑定unicode函数的?在>>> result = unicode(s)
Traceback (most recent call last):
File "", line 1, in
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9a in position 0: ordinal
not in range(128)
>>> result = unicode(s, 'utf-8')
Traceback (most recent call last):
File "", line 1, in
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9a in position 0: invalid s
tart byte
有人能给我解释一下这里发生了什么事吗?提前谢谢。在