from StudentEntity import Student
def loadStudent():
file = open("student.txt","r", encoding = "utf-8")
lines = file.readlines()
student = []
for line in lines:
a = line.split(",")
student.append(Student(a[0], a[1], int(a[2]), a[3].strip("\n")))
file.close()
return students
def saveStudents(student):
file = open("student.txt", "w", encoding="utf-8")
for x in students:
file.write(str(x) + "\n")
file.close()
if __name__ == "__main__":
a = loadStudent()
print(a)
a.append(Student("2024","赵柳",21, 189342424))
print(a)
saveStudents(a)
class Student:
def __init__(self, no, name, age, contact):
self.no = no
self.name = name
self.age = age
self.con