Assignment statements are used to (re)bind names to values and to
modify attributes or items of mutable objects:
...
If the primary is a mapping object (such as a dictionary), the
subscript must have a type compatible with the mapping’s key type, and
the mapping is then asked to create a key/datum pair which maps the
subscript to the assigned object. This can either replace an existing
key/value pair with the same key value, or insert a new key/value pair
(if no key with the same value existed).
正式:
my_map['id']
是一个subscription那么你有:
从这里开始Assignment statements
因此,基本上您是将最近创建的对象绑定/映射到下标,当然,新创建的对象可以被
my_map['id']
引用,因此Python垃圾收集器不能触及它(回收它),它不是一个“悬空指针”,更确切地说,它不是一个没有任何引用的对象旁注:adangling pointer不是一个用于引用没有引用的对象的术语(您是如何使用这个术语的),而是一个对非有效对象的引用(这在Python中是不可能的)
Python中没有指针。Python中有一个绑定到对象的名称
相关问题 更多 >
编程相关推荐