This topic created in 5001 days ago, the information mentioned may be changed or developed.
请教大家,
如何在 python 类里面建一个计数器,以后每建一个这个类的对象,这个类的对象有个成员 self.ID,用来记录在运行期间到底生成过多少该类的对象,就像 java 中的静态成员变量。好久不用咯 =。=
2 replies • 1970-01-01 08:00:00 +08:00
 |
|
1
Hualin Aug 29, 2012
搞明白了。。。。 ==code== class A(object): id = 0 def __init__(self): A.id +=1 ==code==
|