Wizard Book


Programming Python, Web, Android

Python: Menulis Variable ke File dan Membaca ke Variable Menggunakan Pickle

Menulis/Export Isi Variable, List dan Dictionary ke File dan Membaca Kembali menjadi Variabel Lagi Menggunakan Python Pickle

import pickle

a_dict = {1:"A",2:"B",3:"C"}
print(a_dict)

pickle_export = open("export.pickle","wb")
pickle.dump(a_dict, pickle_export)
pickle_export.close()


pickle_import = open("export.pickle","rb")
b_dict = pickle.load(pickle_import)

print(b_dict)

email : contohprogram.com@gmail.com
WA : +6289671400363