問題:sit()和roll_over()函數(shù)中已經(jīng)有print(),在實例調(diào)用函數(shù)的時候,又用了print(),結(jié)果竟然沒有報錯,但是顯示了正確的語句和None,如何理解None?代碼:class Dog():def __init__(self,name,age): self.name = name self.age = agedef sit(self):
print(self.name.title() + " is now sitting.")def roll_over(self):
print(self.name.title() + " rolled over!")my_dog = Dog('willie',6)print(my_dog.roll_over())結(jié)果:
添加回答
舉報
0/150
提交
取消