区分Python中的id()和is以及Python中字符串的intern机制

参考:1. https://blog.csdn.net/lnotime/article/details/81194633

   2.https://segmentfault.com/q/1010000015117621/a-1020000015145284

   3.https://blog.csdn.net/june_young_fan/article/details/79750589

#环境python3.6.3
>>> a='abc'.encode()
>>> b=bytes(a)
>>> id(a)
43426040
>>> id(b)
43426040
>>> id(b)==id(a)
True
>>> id(b) is id(a)
False
>>> id(id(a))
4632304
>>> id(id(b))
4632304
>>> a is b
True

  

posted @ 2019-03-28 09:37  小鲨鱼~  阅读(395)  评论(0编辑  收藏  举报