python语法基础---__slots__、@property、多重继承

slots class student(object): slots = (‘name’,‘age’) #限制student类实例的属性,最多只能是name和age s=student() #实例化s s.name=‘micle’ #为s实例添加name属性,并赋值 s.age=15 print(s.age, s.name) #打印s实例的age和name属性值 class stu_2(stude
相关文章
相关标签/搜索