daily pastebin goal
10%
SHARE
TWEET

Pickle

a guest Jun 14th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Apr 24 12:40:09 2018
  4.  
  5. @author: student
  6. """
  7.  
  8. import pickle
  9.  
  10. """
  11. file = open("../data/inf.txt").read().split("\n")
  12.  
  13. nums = []
  14. fields = file[0].split("|")
  15. del file[0]
  16. i = 0
  17. for line in file:
  18.    file[i] = line.split("|")
  19.    nums.append(file[i][0])
  20.    i+=1
  21.  
  22. data = dict(zip(nums, (dict(zip(fields,x)) for x in file)))
  23.  
  24. #obj = {"one": 123, "two": [1, 2, 3]}
  25. output = open('data.pkl', 'wb')
  26. pickle.dump(data, output, 2)
  27. output.close()
  28. """
  29.  
  30. input_file = open('../data/data.pkl', 'rb')
  31. data2 = pickle.load(input_file)
  32. print(data2)
  33. input_file.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top