#!/usr/bin/env python3# -*- coding: utf-8 -*-class Student:Name = ''Age = 0Score = 0def __init__(self, strName, intAge, intScore):if(type(strName) != str):raise InterruptedError("姓名参数类型不匹配")if(type(intAge) != int):raise InterruptedError("年龄参数类型不匹配")if(type(intScore) != int):raise InterruptedError("成绩参数类型不匹配")self.Age = intAgeself.Name = strNameself.Score = intScoredef ToString(self):return "Name: {0} , Age: {1},Score: {2}".format(self.Name, self.Age, self.Score)'''序列化输出'''def Student2Json(student):return {'name': student.Name, 'age': student.Age, 'score': student.Score}'''反序列化'''def Json2Student(txtJson):return Student(txtJson['name'], txtJson['age'], txtJson['score'])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。