Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. class Mail:
  2. def __init__(self):
  3. self.nadawca = 'brak'
  4. self.odbiorca = 'brak'
  5. self.data = 'brak'
  6. self.tytul = 'brak'
  7. self.tresc = 'brak'
  8.  
  9. def show_mail(self):
  10. print('Pokazuje maila')
  11. print('nadawca: %s' % self.nadawca)
  12. print('odbiorca: %s' % self.odbiorca)
  13. print('data: %s' % self.data)
  14. print('tytul: %s' % self.tytul)
  15. print('tresc: %s' % self.tresc)
  16.  
  17. def load_mail(self, path_to_file):
  18. with open(path_to_file, 'rb') as file1:
  19. for index, line in enumerate(file1):
  20. # utf8 decoding
  21. line = line.decode('utf8', 'ignore')
  22. splitted = line.split(':', 1)
  23.  
  24. if index == 0:
  25. self.nadawca = splitted[1]
  26.  
  27. if index == 1:
  28. self.odbiorca = splitted[1]
  29.  
  30. if index == 2:
  31. self.data = splitted[1]
  32.  
  33. if index == 3:
  34. self.tytul = splitted[1]
  35.  
  36. if index == 4:
  37. self.tresc = splitted[1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement