Q70186 - 2025挑战赛Py提高组选择题20
统计题目( 单选题 )
阅读程序,以下代码使用了哪种内存管理技术?( )。
|
import weakref
class Node: def __init__(self, value): self.value = value self._parent = None self.children = []
@property def parent(self): return self._parent() if self._parent else None
@parent.setter def parent(self, node): self._parent = weakref.ref(node)
parent = Node("parent") child = Node("child") child.parent = parent parent.children.append(child) |

关注我们