有代碼:class A: @staticmethod def g(): A.__z = 4print(dir(A))A.g()print(dir(A)) # A has attribute _A__zA.__m = 5print(dir(A)) # A has attribute _A__z and __m為什么名稱__m不被改成_A__m而是__z呢?
在靜態(tài)函數(shù)內(nèi)添加類屬性與在類外進(jìn)行賦值之間的區(qū)別
動(dòng)漫人物
2021-03-05 21:18:20