“pickle.load python” Code-Antworten

pickle.load python

import pickle
# load : get the data from file
data = pickle.load(open(file_path, "rb"))
# loads : get the data from var
data = pickle.load(var)
Doubtful Dingo

Pickle.Dump Python

import pickle
# dump : put the data of the object in a file
pickle.dump(obj, open(file_path, "wb"))
# dumps : return the object in bytes
data = pickle.dump(obj)
Doubtful Dingo

Python Pickle Modul

# Python3 program to illustrate store 
# efficiently using pickle module 
# Module translates an in-memory Python object 
# into a serialized byte stream—a string of 
# bytes that can be written to any file-like object.
  
import pickle
  
def storeData():
    # initializing data to be stored in db
    Omkar = {'key' : 'Omkar', 'name' : 'Omkar Pathak',
    'age' : 21, 'pay' : 40000}
    Jagdish = {'key' : 'Jagdish', 'name' : 'Jagdish Pathak',
    'age' : 50, 'pay' : 50000}
  
    # database
    db = {}
    db['Omkar'] = Omkar
    db['Jagdish'] = Jagdish
      
    # Its important to use binary mode
    dbfile = open('examplePickle', 'ab')
      
    # source, destination
    pickle.dump(db, dbfile)                     
    dbfile.close()
  
def loadData():
    # for reading also binary mode is important
    dbfile = open('examplePickle', 'rb')     
    db = pickle.load(dbfile)
    for keys in db:
        print(keys, '=>', db[keys])
    dbfile.close()
  
if __name__ == '__main__':
    storeData()
    loadData()
Enchanting Eagle

Ähnliche Antworten wie “pickle.load python”

Fragen ähnlich wie “pickle.load python”

Weitere verwandte Antworten zu “pickle.load python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen