fork download
  1. # your code goes here
  2. class Dog:
  3. legs = 4
  4. def __init__(self, name, color):
  5. self.name = name # 名字
  6. self.color = color # 颜色
  7. def dog_info(self):
  8. print(f"名字:{self.name}", f"腿数:{self.legs}条", f"颜色:{self.color}")
  9.  
  10. # 实例化Dog对象
  11. dog = Dog("小汪", "黑色")
  12. dog.dog_info()
Success #stdin #stdout 0.09s 14044KB
stdin
Standard input is empty
stdout
名字:小汪 腿数:4条 颜色:黑色