小编Zok*_*kis的帖子

unicode字符串中的内存位置

我知道有人解释为什么当我在Python 2.7中创建相同的unicode字符串时,它们不会指向内存中的相同位置,因为在"普通"字符串中

>>> a1 = 'a'
>>> a2 = 'a'
>>> a1 is a2
True
Run Code Online (Sandbox Code Playgroud)

好吧那就是我的预期,但是

>>> ua1 = u'a'
>>> ua2 = u'a'
>>> ua1 is ua2
False
Run Code Online (Sandbox Code Playgroud)

为什么?怎么样?

python unicode python-2.7

5
推荐指数
1
解决办法
508
查看次数

标签 统计

python ×1

python-2.7 ×1

unicode ×1