2条回答 默认 最新
- CSDN专家-黄老师 2021-06-02 11:19关注
class Student(object): def __init__(self, id, name, sex, age, school): self.id = id self.name = name self.sex = sex self.age = age self.school = school print(self.id, self.name, self.sex, self.age, self.school) r = [] f = open('stu.txt', 'r', encoding='utf-8') for t in f.readlines(): rs = t.strip().split(' ') r.append(rs) for i in r: id, name, sex, age, school = i Student(id, name, sex, age, school)
如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报