Table des matières

Pickle

Utilisation basique

Source

import pickle
import os
 
data = None
if os.path.exists("data.pickle"):
    with open("data.pickle", "rb") as f:
        data = pickle.load(f)
else:
    data = [1, 2, 3, 4]
    with open("data.pickle", "wb") as f:
        pickle.dump(data, f)