跳到主要内容

AttributeTreeNode

类数据类源码

AttributeTreeNode(
name: str,
attrs: dict[str, Any] = dict(...),
children: dict[str, AttributeTreeNode] = dict(...)
)

成员属性 (attribute) 树中的节点。

字段​

字段类型必选
说明
namestr当前节点的部分名称。
attrsdict[str, Any]当前节点的额外成员属性。
childrendict[str, AttributeTreeNode]当前节点的子成员/子节点。

方法​

add​

self.add(segments: Sequence[str], attrs: Mapping[str, Any] | None = None)

按照名称段,递归地将成员属性添加到树中。

输入​

参数类型必选
说明
segmentsSequence[str]一条名称段构成的序列。每段代表路由中一个节点的部分名称。如果提供了空列表,亦即[],就会将信息更新在当前(这个)节点中。
attrsMapping[str, Any] | None要添加到目标节点的成员属性。对应的目标节点、则通过将segments路由到当前节点来获取。