code show as below:
# -*- coding:gb2312 -*-
class Dog:
#属性
#方法
def __init__(self,new_name,new_age):
self.name = new_name
self.age = new_age
def show(self):
print(self.name)
print(self.age)
dog = Dog("卡卡",10)
dog.show()
#----------------------------分割线------------------------------------
class Cat:
#属性
#方法
def __init__(self):
self.name = self.get_name(new_name)
self.age = self.get_age(new_age)
def get_name(self,new_name):
return new_name
def get_age(self,new_age):
return new_age
def show(self):
print(self.name)
print(self.age)
#cat = Cat()
cat = Cat()
cat.get_name("哈哈")
cat.get_age(20)
cat = Cat()
dog.show
Results of the:
My question:
The program prompts that new_name cannot be found
I clearly wrote it down during class
I don’t know why the system prompts that it cannot be found?
Highest priority
Initialization method
__init__
is executed beforeget_name