""" StudentScoreInfo.py 学生成绩类 date 2023-06-16 edit: Geovin Du,geovindu, 涂聚文 ide: PyCharm 2023.1 python 11 """ import datetime import sys import os class StudentScore(object): """ 学生成绩类 """ def __init__(self,ScoreId:int,StudentId:int,CourseId:int,Score:float): """ 构造函数(方法) :param ScoreId: ID :param StudentId:学生ID :param CourseId:课程ID :param Score:成绩ID """ self._StudentId = StudentId self._CourseId = CourseId self._Score = Score self._ScoreId = ScoreId def __init__(self): """ 必须写后 """ self._StudentId = 0 self._CourseId = 0 self._Score = 0 self._ScoreId = 0 ''' def __del__(self): """ :return: """ print(f"{self._StudentId}") ''' def setStudentId(self,StudentId): """ :param StudentId: :return: """ self._StudentId=StudentId def getStudentId(self): """ :return: """ return self._StudentId def setCourseId(self,CourseId): """ :param CourseId: :return: """ self._CourseId=CourseId def getCourseId(self): """ :return: """ return self._CourseId def setScore(self,Score): """ :param Score: :return: """ self._Score=Score def getScore(self): """ :return: """ return self._Score def setScoreId(self,ScoreId): """ :param ScoreId: :return: """ self._ScoreId=ScoreId def getScoreId(self): """ :return: """ return self._ScoreId def __str__(self): """ :return: """ return f"{self._ScoreId},{self._StudentId},{self._Score},{self._CourseId}" def __iter__(self): """ :return: """ return self def __next__(self): """ :return: """ self._ScoreId, self._StudentId, self._CourseId, self._Score = self._ScoreId, self._StudentId, self._CourseId, self._Score return self._ScoreId,self._StudentId,self._CourseId,self._Score def __getitem__(self,n): """ :param n: :return: """ for x in range(n): self._ScoreId, self._StudentId, self._CourseId, self._Score=self._ScoreId,self._StudentId,self._CourseId,self._Score return self._ScoreId, self._StudentId, self._CourseId, self._Score def __getattr__(self,name): """ :param name: :return: """ if name=="ScoreId": return self._ScoreId if name=="StudentId": return self._StudentId if name=="CourseId": return self._CourseId if name=="Score": return self._Score def __ceil__(self): """ :return: """ #return f"{self._ScoreId},{self._StudentId},{self._CourseId},{self._Score}" return (self._ScoreId,self._StudentId,self._CourseId,self._Score)
调用:
stuscroe=Model.StudentScoreInfo.StudentScore() stuscroe.setStudentId(1) stuscroe.setScore(80) stuscroe.setScoreId(5) stuscroe.setCourseId(2) print(stuscroe.Score)
标签:ScoreId,StudentId,return,python,self,object,专有,Score,._ From: https://www.cnblogs.com/geovindu/p/17500669.html