实验5
作者:互联网
'''student.py'''
class StudentDoc:
'''学生档案管理'''
def __init__(self,students_number,studens_name,major,python_score):
self._students_number=students_number
self._studens_name=studens_name
self._major=major
self._python_score=python_score
def score(self):
return print(f"{self._studens_name}的python课程分数{self._python_score}",end="\n")
def modify_score(self,sore):
self._python_score=sore
def info(self):
print(f"学号:{self._students_number}")
print(f"姓名:{self._studens_name}")
print(f"专业:{self._major}")
#测试类
def main():
a1=StudentDoc("202013170066","Bob","生态学",90)
a2=StudentDoc("202013170052","Mary","生态学",85)
a1.info()
a2.info()
a1.score()
a2.score()
if __name__ == '__main__':
print('模块信息: ', __doc__)
print('StudentDoc类信息: ', StudentDoc.__doc__)
main()
import student#导入模块
s1=student.StudentDoc("202013170066","Bob","生态学",90)
s2=student.StudentDoc("202013170052","Mary","生态学",85)
s1.modify_score(75)
s1.info()
s1.score()
s2.modify_score(60)
s2.info()
s2.score()
调用自定义函数未成功,无截图
标签:__,python,self,._,score,实验,StudentDoc 来源: https://www.cnblogs.com/lengsz/p/14829487.html