代码
class MyClass(object):
def MyMethod(self):
print(self)
MyObject = MyClass()
print(MyObject.MyMethod())
输出
<__main__.MyClass object at 0x0000000002B70E10 >
__main__
是什么意思? self
参数中传递的是什么?
最佳答案
What does this
__main__
mean?
直接调用的脚本被认为是 __main__
模块。它可以像任何其他模块一样导入和访问。
And what is being passed in the self parameter?
MyObject
中包含的引用。
关于Python - <__main__.MyClass 对象在 0x0000000002B70E10>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16868544/