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

class A:
    num = 0

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

a = A()
b = A()
print(A.num)
View Code

 

posted @ 2018-03-05 10:35  golangav  阅读(169)  评论(0编辑  收藏  举报