Self在python的作用
提問(wèn)人:楊紫紅發(fā)布時(shí)間:2020-11-18
Self代表類自己的對(duì)象
調(diào)用函數(shù)時(shí)這個(gè)參數(shù)不是必須的
一個(gè)函數(shù)可以調(diào)用另外一個(gè)函數(shù)
class Giraffes(Mammals):
def find_food(self):
self.move()
print("I've found food!")
self.eat_food()
def eat_leaves_from_trees(self):
self.eat_food()
def dance_a_jig(self):
self.move()
self.move()
self.move()
self.move()
繼續(xù)查找其他問(wèn)題的答案?
相關(guān)視頻回答
點(diǎn)擊加載更多評(píng)論>>