Find us on Facebook

Thursday, December 13, 2018

Pickling



Aim: Implement a Program to implement the concept of pickling.
Algorithm:
1.Start
2.Create a dictionary
3.Save a dictionary into a pickle file.
4. Load the dictionary back from the pickle file.
5.Dispaly the dictionary.
6.Stop
Program:
 # Save a dictionary into a pickle file.
    import pickle
    favorite_color = { "lion": "yellow", "kitty": "red" }
     pickle.dump( favorite_color, open( "save.p", "wb" ) )
# Load the dictionary back from the pickle file.
    import pickle
    favorite_color = pickle.load( open( "save.p", "rb" ) )
print favorite_color
    # favorite_color is now { "lion": "yellow", "kitty": "red" }
Output: 

{ "lion": "yellow", "kitty": "red" }



0 Comments:

Popular Posts

Text Widget

Search This Blog

Powered by Blogger.

Blogger Pages

Like Canvas?

Sponsor

Footer Widgetized Areas

About Canvas

About Canvas

Subscribe Us

About

Text Widget

Tags

Total Pageviews

print pdf

cal

Most Popular

    TUPLES
 LIST and SLICING
      ASCII VALUE
Copyright © KTU Btech Cse Python Lab Manuals | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates