实验五

5. 实验任务5:自定义模块及模块导入编程

class StudentDoc:
    def __init__(self,xh,name,zy,fs):
        self._xh=xh
        self._name=name
        self._zy=zy
        self._fs=fs
    def info(self):
        print(f'学号:{self._xh}')
        print(f'姓名:{self._name}')
        print(f'专业;{self._zy}')
        print(f'python分数:{self._fs}')
    def get_fs(self):
        return self._fs
    def xg_fs(self,newfs):
        self._fs=newfs
        return newfs
def main():
    a1 = StudentDoc('123456', 'dmn', 'python', '88')
    a1.xg_fs(99)
    a1.info()
if __name__ == '__main__':
    main()

 

 

from student import StudentDoc as www
u1 = www('123','hhh','yy','78')
u1.xg_fs(100)
u1.info()
u2 = www('456','kkk','sx','88')
u2.info()

posted on 2021-05-25 17:27  wxqsdmn  阅读(52)  评论(1编辑  收藏  举报

导航