python 定义类时,内部方法的互相调用

每次调用内部的方法时,方法前面加 self.
举例:

例子参考百度知道里面的回答

class MyClass:
    def __init__(self):
        pass
    def func1(self):
        # do something
        print('a')   #for example      
        self.common_func()
     def func2(self):
        # do something
        self.common_func()
         
     def common_func(self):
         pass

猜你喜欢

转载自blog.csdn.net/ganghaod/article/details/83476018