# coding: utf-8

class A():
    params = 0 # 类变量，也称为“静态变量”

    def add(self):
        self.params += 1


if __name__ == "__main__":
    a = A()  # 实例化对象1
    b = A()  # 实例化对象2
    print a.params  # 执行结果为: 0
    print b.params  # 执行结果为: 0
    print A.params # 执行结果为: 0

    a.add()
    print a.params  # 执行结果为: 1
    print b.params  # 执行结果为: 0
    print A.params # 执行结果为: 0

    b.add()
    print a.params # 执行结果为: 1
    print b.params # 执行结果为: 1
    print A.params # 执行结果为: 0

@@ -29,34 +29,51 @@
     
-params = 0 # %E7%B1%BB%E5%8F%98%E9%87%8F%EF%BC%8C%E4%B9%9F%E7%A7%B0%E4%B8%BA%E2%80%9C%E9%9D%99%E6%80%81%E5%8F%98%E9%87%8F%E2%80%9D
+def __init__(self):%0A        self.params = 0
 %0A%0A  
@@ -252,38 +252,8 @@
 %E4%B8%BA: 0
-%0A    print A.params # %E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C%E4%B8%BA: 0
 %0A%0A  
@@ -327,38 +327,8 @@
 %E4%B8%BA: 0
-%0A    print A.params # %E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C%E4%B8%BA: 0
 %0A%0A  
@@ -359,32 +359,32 @@
 rams # %E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C%E4%B8%BA: 1%0A
+
     print b.para
@@ -401,34 +401,4 @@
 : 1%0A
-    print A.params # %E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C%E4%B8%BA: 0%0A

add __init__