[Python]Python Class 中的 函数定义中的 self

In [80]: class MyClass001:

....: def selfDemo(self):
....: print 'My Demo'
....:

In [81]: p = MyClass001()

In [82]: p.selfDemo()
My Demo

In [83]:

In [83]: class MyClass002:
....: def selfDemo(self):
....: print self
....:

In [84]: p=MyClass002()

In [85]: p.selfDemo()
<__main__.MyClass002 instance at 0x7f308a0394d0>

In [86]:

原文地址:https://www.cnblogs.com/gaojian/p/7588465.html