“Читать Pickle File Python” Ответ

мариновать словарь

import pickle #credits to stack overflow user= blender

a = {'hello': 'world'}

with open('filename.pkl', 'wb') as handle:
    pickle.dump(a, handle, protocol=pickle.HIGHEST_PROTOCOL)

with open('filename.pkl', 'rb') as handle:
    b = pickle.load(handle)

print (a == b)
Shiny Snail

Читать файл Pickle

with open('filename', 'rb') as f:
    x = pickle.load(f)
Wrong Wallaby

Создать Pickle File Python

import pickle
file_name='my_file.pkl'
f = open(file_name,'wb')
pickle.dump(my_data,f)
f.close()
Tremendous Enceladus

Читать Pickle File Python

data = pd.read_pickle('dtm.pkl')
Distinct Dragonfly

Python Open Pickle File

'''3 ways to open file with python (e.g: 'my_pickle_file.pkl)':'''

# ORIGINAL
with open('my_pickle_file.pickle', 'rb') as f :
    pickle_file = pickle.load(f)

# QUICK
pickle_file =  pickle.load(open("my_pickle_file.pickle", 'rb'))

# PANDAS
pickle_file = pd.read_pickle('my_pickle_file.pickle')
Tirbo06

Читать Pickle File Python

import pandas as pd
#the object type is the one defined in the pickle, it is not a dataframe
object = pd.read_pickle(r'filepath')
Yesid Cano Castro

Ответы похожие на “Читать Pickle File Python”

Вопросы похожие на “Читать Pickle File Python”

Больше похожих ответов на “Читать Pickle File Python” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования