後,我跑了 「a.method」,爲什麼sys.getrefcount(一)共有3款?沒有新的變量稱爲對象一些關於sys.getrefcount
class A(object):
def method(): pass
import sys
a=A()
sys.getrefcount(a) # returns 2
a.method
<bound method A.method of <__main__.A object at 0x7f1e73059b50>>
sys.getrefcount(a) # returns 3
請學習如何創建一個如何在發佈問題之前創建最小,完整和可驗證的示例(https://stackoverflow.com/help/mcve) – mrid
您正在使用IPython還是其他IDE? –