Pickle Module in Python

    

   import pickle

# pickling a python object
mylist = ["waqas", "sheeraz",{"sheeraz": "haroon", "sheer": "veer"}, "haroon", "farrukh"]
file_object = open("mylist.pkl", "wb") # write as binary file
pickle.dump(file=file_object, obj=mylist)
file_object.close()

# unpickling into python object
fileb = open("mylist.pkl", "rb") # read binary file
python_obj = pickle.load(file=fileb)
print(python_obj)
fileb.close()

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes