【发布时间】:2012-09-09 09:07:29
【问题描述】:
可能重复:
Old style and new style classes in Python
python class inherits object
有什么区别
class foo:
和
class foo(object):
谁能解释为什么我们在类定义中使用对象?
【问题讨论】:
可能重复:
Old style and new style classes in Python
python class inherits object
有什么区别
class foo:
和
class foo(object):
谁能解释为什么我们在类定义中使用对象?
【问题讨论】:
在 Python 2.x 中,第一个声明是旧式类,第二个版本是新式类。对于新代码,您应该始终使用新型类。
在 Python 3 中,所有类都是新式的,所以没有区别。
【讨论】: