为什么派生类中的类中没有'__dict__'?

考虑一下:

class Base:
  pass

class Derived(Base):
  pass

print(Base.__dict__)
print(Derived.__dict__)

print('__dict__' in Base.__dict__)
print('__dict__' in Derived.__dict__)

输出为:

{'__module__': '__main__','__dict__': <attribute '__dict__' of 'Base' objects>,'__weakref__': <attribute '__weakref__' of 'Base' objects>,'__doc__': None}
{'__module__': '__main__','__doc__': None}
True
False

为什么'__dict__'类缺少'__weakref__'Derived键? 这是什么意思/影响?

iCMS 回答:为什么派生类中的类中没有'__dict__'?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2288880.html

大家都在问