From the course: Level Up: Python
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Save a dictionary - Python Tutorial
From the course: Level Up: Python
Save a dictionary
(gaming music) - Python dictionaries are incredibly useful for storing and retrieving information, but that data is held in memory. So when the program exits, it disappears. But what if you need that dictionary again later? Your goal for this challenge is to write a function to save a Python dictionary object to file. Your safe function should take two input arguments for the dictionary to save, and an output file path. Now, saved data's only useful if you can retrieve it later, so you should also write a second function to load the saved dictionary back into Python. That load function should take a file path to the saved dictionary as its input, and then return the retrieved dictionary object. Pause the video now to create your own solution. Then I'll show you how I solve this challenge. When you need to preserve something for later, you pickle it. So that's what I did for my solution. In Python, pickling…
Contents
-
-
-
Find prime factors3m 11s
-
(Locked)
Identify a palindrome2m 48s
-
(Locked)
Sort a string3m 2s
-
(Locked)
Find all list items3m 12s
-
(Locked)
Play the waiting game2m 22s
-
(Locked)
Save a dictionary3m 13s
-
(Locked)
Schedule a function3m 16s
-
(Locked)
Send an email3m 12s
-
(Locked)
Simulate dice3m 16s
-
(Locked)
Count unique words3m 12s
-
(Locked)
Generate a password3m 59s
-
(Locked)
Merge CSV files3m 35s
-
(Locked)
Solve a sudoku4m 8s
-
(Locked)
Build a zip archive3m 43s
-
(Locked)
Download sequential files4m 2s
-