Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

save variable python pickle

import pickle
  
# Create a variable
myvar = [{'This': 'is', 'Example': 2}, 'of',
         'serialisation', ['using', 'pickle']]
  
# Open a file and use dump()
with open('file.pkl', 'wb') as file:
      
    # A new file will be created
    pickle.dump(myvar, file)
Comment

PREVIOUS NEXT
Code Example
Python :: python string to list new line 
Python :: line plot python only years datetime index 
Python :: detailview 
Python :: install os conda 
Python :: reversed python 
Python :: multiplication table python 
Python :: dataframe subtract value from previous row 
Python :: how to kill a script if error is hit python 
Python :: gaussian filter 
Python :: pandas difference between rows in a column 
Python :: insert list python 
Python :: load python file in jupyter notebook 
Python :: closedxml hide column 
Python :: animations on canvas tkinter 
Python :: pandas loc for list 
Python :: convert 2d aray into 1d using python 
Python :: how to end an infinite loop in specific time python 
Python :: calculate perimeter of rectangle in a class in python 
Python :: python discord mention user 
Python :: how to change the disabled color in tkinter 
Python :: wxpython icon 
Python :: check for string in list py 
Python :: how to make a dice program in python 
Python :: tf.reduce_sum() 
Python :: creating a bar plot bar | creating a bar chart 
Python :: pandas ticks fontsize 
Python :: find keys to minimum value in dict 
Python :: pandas df to list of dictionaries 
Python :: How do you create an matrix of random integers in Numpy? 
Python :: create virtualenv python3 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =