Python特殊函数__len()__使函数len()能够作用于类中的变量,例: 12345678910 class (object): def __init__(self, *args): self.names = args def __len__(self): return len(self.names)s = Namespace('jia', 'tim')print( len(s) ) 赞微海报分享
近期评论