标签:调用 它的 绑定 定义 attr student 函数 规则 int
class Student1:
school = 'xiwangzhongxue'
def __init__(self,name,age):
self.name = name
self.age = age
def choice(self):
print(f'{self.name}选课...')
def study(self):
print('学习....')
class Student1:
school = 'xiwangzhongxue'
def __init__(self,name,age):
self.name = name
self.age = age
def choice(self):
print(f'{self.name}选课...')
def study(self):
print('学习....')
stu1 = Student('小明', 18)
stu2 = Student('小红', 17)
print(stu1.name)
print(stu1.school)
小明
xiwangzhongxue
print(Student.choice(123))
‘int‘ object has no attribute ‘name‘
class Student1:
school = 'xiwangzhongxue'
def __init__(self, name,age):
self.name = name
self.age = age
def choice(self):
print(f'{self.name}选课...')
def study(self):
print('学习....')
stu1 = Student1('小明',18)
stu1.choice()
stu2 = Student1('小红',20)
stu2.choice()
小明选课...
小红选课...
标签:调用 它的 绑定 定义 attr student 函数 规则 int
原文地址:https://www.cnblogs.com/xichenHome/p/11414729.html