标签:append add style elf class def trick self tricks
class Dog: def __init__(self, name): self.name = name self.tricks = [] # creates a new empty list for each dog def add_trick(self, trick): self.tricks.append(trick) >>> d = Dog(‘Fido‘) >>> e = Dog(‘Buddy‘) >>> d.add_trick(‘roll over‘) >>> e.add_trick(‘play dead‘) >>> d.tricks [‘roll over‘] >>> e.tricks [‘play dead‘]
标签:append add style elf class def trick self tricks
原文地址:https://www.cnblogs.com/youge-OneSQL/p/9708349.html