반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/11   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Archives
Today
Total
관리 메뉴

chargingport

Python dictionary 저장/불러오기 본문

NOTES/PYTHON

Python dictionary 저장/불러오기

chargingport 2023. 9. 5. 11:12
반응형
import pickle

dict = {'A': 1, 'B': 2, 'C': 3}

# dictionary를 dictionary.pkl에 저장
with open("dictionary.pkl", "wb") as output_file:
    pickle.dump(dict, output_file) 

# dictionary.pkl을 dictionary로 저장
with open("dictionary.pkl", "rb") as input_file:
    newDict = pickle.load(input_file)

print(newDict)
$ python3 main.py 

{'A': 1, 'B': 2, 'C': 3}

dictionary.pkl 파일생성 확인

반응형