Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from LibrarySystem.scr.Student import *
- class UserDatabase:
- student_list = []
- def readFromUserTxt(self):
- with open("users.txt", "r") as f:
- for line in f:
- data = line.strip().split(';')
- try:
- student = Student(data[0], data[1], data[2], data[3], data[4])
- if len(data) > 5:
- for i in range(5, len(data)):
- student.issued_books.append(data[i])
- self.student_list.append(student)
- except:
- pass
- def writeToUserTxt(self):
- with open("users.txt", "w") as f:
- for s in self.student_list:
- f.write("{};{};{};{};{}".format(s.id, s.name, s.lastname, s.login, s.password))
- f.write("\n")
- def print_users(self):
- for user in self.student_list:
- print("{} - {} {}".format(user.id, user.name, user.lastname))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement