标签:图片 lse 用法 输入参数 __init__ 输入 面向 details sel
class Student(object):
def __init__(self, name, score):
self.__name = name
self.__score = score
def print_score(self):
print("%s: %s" %(self.__name, self.__score))
def get_name(self):
return self.__name
def get_score(self):
return self.__score
def set_score(self, score):
self.__score = score
def get_grade(self):
if self.__score >= 90:
return 'A'
elif self.__score >= 60:
return 'B'
else:
return 'C'
if __name__ == "__main__":
student = Student("Hugh", 99) # 输入参数
student.print_score() # 1
student.set_score(88) # 改变分数
print(student.get_name()) # 2
print(student.get_score()) # 3
student.print_score() # 4
print(student.get_grade()) # 5
标签:图片 lse 用法 输入参数 __init__ 输入 面向 details sel
原文地址:https://www.cnblogs.com/HongjianChen/p/11589166.html