Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. def serialize_to_str_file(file_path, object):
  2.     with open(file_path, 'w') as file:
  3.         for line in object:
  4.             file.write(str(line) + '\n')
  5.  
  6.  
  7. def deserialize_from_str_file(file_path):
  8.     lst = []
  9.     with open(file_path, 'r') as file:
  10.         for line in file:
  11.             mline = line.replace('\n', "")
  12.             ev = ast.literal_eval(mline)
  13.             lst.append(ev)
  14.     return lst
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement