类的特殊属性

类的特殊属性

  • dict

作用:获取实例对象所绑定的所有属性和方法的字典

class Student:
    def __init__(self, name, age, score):
        self.name = name
        self.age = age
        self.score = score

s1 = Student("shaodi", 17, 98)
# __dict__特殊属性,获取实例对象所绑定的所有属性和方法的字典
print(s1.__dict__)

猜你喜欢

转载自www.cnblogs.com/huanyinglvtuan/p/12616654.html