by
1
8
5,041
5
Top 1% !
Popular
Famous
Pearl of Wisdom
Tagged
Easy-to-find
Specified
OpenSource
Popularity: 1582nd place
Created
Modified Oct 24, 2013

Published on:

Architecturex86_64
LanguagePython
LicenseMIT_X11
OSLinux

Using Pickle To load serialized Objects from file In Python - String Deserialization

Once you have pickled some data and saved to a txt file, you may want to retrieve the data back to a valid and usable python object at run time.

To restore an object to memory, just load the file using pickle, assigning the value to the object itself.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/11809/Using-Pickle-To-load-serialized-Objects-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
import pickle # The file with serialized data to retrieve fileHandler = open(filename, 'r') # The data is stored into my_object variable my_object = pickle.load(fileHandler) fileHandler.close()

Other Steps and Solutions

If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus