更新时间:2023-01-02 21:33:41
namedtuple()
是tuple
子类的工厂函数.在这里,'whatsmypurpose'
是类型名称.创建命名元组时,将在内部创建具有此名称(whatsmypurpose
)的类.
namedtuple()
is a factory function for tuple
subclasses. Here, 'whatsmypurpose'
is the type name. When you create a named tuple, a class with this name (whatsmypurpose
) gets created internally.
您可以通过使用以下详细参数来注意到这一点:
You can notice this by using the verbose argument like:
Point=namedtuple('whatsmypurpose',['x','y'], verbose=True)
您也可以尝试type(p)
进行验证.
Also you can try type(p)
to verify this.