相关疑难解决方法(0)

"对象没有__dict__,因此您无法将任意属性分配给对象类的实例."

来自https://docs.python.org/3.3/library/functions.html#object

object没有__dict__,所以你不能将任意属性分配给object类的实例.

为什么" object没有__dict__"?这个对我有用

>>> object.__dict__
mappingproxy({'__repr__': <slot wrapper '__repr__' of 'object' objects>, '__hash__': <slot wrapper '__hash__' of 'object' objects>, '__subclasshook__': <method '__subclasshook__' of 'object' objects>, '__ne__': <slot wrapper '__ne__' of 'object' objects>, '__format__': <method '__format__' of 'object' objects>, '__new__': <built-in method __new__ of type object at 0xa3dc20>, '__doc__': 'The most base type', '__class__': <attribute '__class__' of 'object' objects>, '__dir__': <method '__dir__' of 'object' objects>, '__delattr__': <slot wrapper '__delattr__' of 'object' …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

-3
推荐指数
1
解决办法
1249
查看次数

标签 统计

python ×1

python-3.x ×1