【发布时间】:2015-05-20 12:32:02
【问题描述】:
在 Python 2.7 中:
In [2]: utf8_str = '\xf0\x9f\x91\x8d'
In [3]: print(utf8_str)
????
In [4]: unicode_str = utf8_str.decode('utf-8')
In [5]: print(unicode_str)
????
In [6]: unicode_str
Out[6]: u'\U0001f44d'
In [7]: len(unicode_str)
Out[7]: 2
既然unicode_str 只包含一个unicode 代码点(0x0001f44d),为什么len(unicode_str) 返回2 而不是1?
【问题讨论】:
标签: python python-2.7 unicode python-unicode