Python - <__main__.MyClass 对象在 0x0000000002B70E10>

标签 python python-3.x

代码

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/

相关文章:

python - 如何在 python 中使用正则表达式查找某些单词?

python - 无法在 python 中跳出 while 循环

python - python中的asyncio.sleep()是如何实现的?

python-3.x - 与外部 MQTT 代理连接时出现问题

python - Migrate extension to python3,丰富对比

python - Django 自动转义在 render_to_string(template) 中不起作用?

python - 我正在处理一个银行数据集,我必须只使用 'experience in job' 列的整数部分

python - 创建具有两个值的字典时遗漏的值

Python:输入相同但输出不同

python - 将整数列表、数字字符串转换为整数列表