因为,不加self, 你可能会执行类外的同名函数eat
def eat(thing):
print(thing,'--->执行了类外函数')
class Dog:
def eat(self, thing):
print('执行了类内函数', thing)
def run(self):
eat(2)
Dog().run()
做一个标记
因为,不加self, 你可能会执行类外的同名函数eat
def eat(thing):
print(thing,'--->执行了类外函数')
class Dog:
def eat(self, thing):
print('执行了类内函数', thing)
def run(self):
eat(2)
Dog().run()
做一个标记