区分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

  

做一枚奔跑的老少年!
原文地址:https://www.cnblogs.com/xiaoshayu520ly/p/10612888.html