1. 统计一个类被实例了多少次

class A:
    num = 0

    def __init__(self):
        A.num += 1

a = A()
b = A()
print(A.num)
View Code
原文地址:https://www.cnblogs.com/golangav/p/8507672.html