python类可以任意添加属性
class A(object):
def __init__(self):
self.name = "zhangsan"
self.age = 18
a1 = A()
print("类外打印:", a1.name)
print("类外打印:", a1.age)
A.score = 100
print("类外打印:", A.score)
输出
python类可以任意添加属性
class A(object):
def __init__(self):
self.name = "zhangsan"
self.age = 18
a1 = A()
print("类外打印:", a1.name)
print("类外打印:", a1.age)
A.score = 100
print("类外打印:", A.score)
输出
转载于:https://www.cnblogs.com/andy9468/p/9686827.html