Horje
save thing in pickle python Code Example
save thing in pickle python
import pickle

a = {'hello': 'world'}

with open('filename.pickle', 'wb') as handle:
    pickle.dump(a, handle, protocol=pickle.HIGHEST_PROTOCOL)

with open('filename.pickle', 'rb') as handle:
    b = pickle.load(handle)

print a == b
create pickle file python
import pickle
file_name='my_file.pkl'
f = open(file_name,'wb')
pickle.dump(my_data,f)
f.close()
pickle.load python
import pickle
# load : get the data from file
data = pickle.load(open(file_path, "rb"))
# loads : get the data from var
data = pickle.load(var)
save a file as a pickle
with open('mypickle.pickle', 'wb') as f:
    pickle.dump(some_obj, f)

# note that this will overwrite any existing file
# in the current working directory called 'mypickle.pickle'




Python

Related
pandas version check in python Code Example pandas version check in python Code Example
import seaborn Code Example import seaborn Code Example
sns import python Code Example sns import python Code Example
module 'tensorflow.python.framework.ops' has no attribute '_tensorlike' Code Example module 'tensorflow.python.framework.ops' has no attribute '_tensorlike' Code Example
hackerrank python test Code Example hackerrank python test Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8