python特殊函数__len__(self)

__len__ 若是一个类表现得像一个list,要获取有多少个元素,就得用len()函数。html 要让len()函数工做正常,类必须提供一个特殊方法__len__(),它返回元素的个数。python 例如,咱们写一个 Students 类,把名字传进去:web class Students(object): def __init__(self, *args): self.
相关文章
相关标签/搜索