摘要: 使用__slots__但是,如果我们想要限制class的属性怎么办?比如,只允许对Student实例添加name和age属性。为了达到限制的目的,Python允许在定义class的时候,定义一个特殊的__slots__变量,来限制该class能添加的属性: class Student(object) 阅读全文
posted @ 2019-04-22 09:28 吴之家 阅读(178) 评论(0) 推荐(0) 编辑