apple: <__main__.Apple object at 0x7fa3a9202ed0>,2
再看绑定关系:
1
2
print(a.get_apple)
<bound method Apple.get_apple of <__main__.Apple object at 0x7fa3a9202ed0>>
类的普通方法,只能用类的实例去使用。如果用类调用普通方法,出现如下错误:
1
2
Apple.get_apple(2)
Traceback (most recent call last): File "static.py", line 22, in <module> Apple.get_apple(2) TypeError: unbound method get_apple() must be called with Apple instance asfirst argument (got int instance instead)