Loading Data from a Pickle File
We'll cover the following...
Now switch to your second Python Shell — i.e. not the one where you created the entry
dictionary.
Press + to interact
shell = 2print (shell) #①#2print (entry) #②#Traceback (most recent call last):# File "/usercode/__ed_file.py", line 5, in <module># print (entry) #\u2461#NameError: name 'entry' is not defined
Press + to interact
import picklewith open('entry.pickle', 'rb') as f: #③entry = pickle.load(f) #④print (entry) #⑤#{'comments_link': None,# 'internal_id': b'\xDE\xD5\xB4\xF8',# 'title': 'Dive into history, 2009 edition',# 'tags': ('diveintopython', 'docbook', 'html'),# 'article_link':# 'http://diveintomark.org/archives/2009/03/27/dive-into-history-2009-edition',# 'published_date': time.struct_time(tm_year=2009, tm_mon=3, tm_mday=27, tm_hour=22, tm_min=20, tm_sec=42, tm_wday=4, tm_yday=86, tm_isdst=-1),# 'published': True}
① This is Python Shell #2.
② There is no entry
variable defined here. You defined an entry
variable in Python Shell #1, but that’s a ...
Access this course and 1400+ top-rated courses and projects.