1 getrefcount()方法 getrefcount()方法位于sys中,在使用的时候,我们应该加上这句话 import sys getrefcount()方法测量的永远比实际值多一,具体代码如下: ''' 2020.3.17 @BUG369456 测量对象的引用个数 ''' import sys class Test: pass test1 = Test() test2 = test1 print(sys.getrefcount(test1)) 这段代码的运行结果为: