본문 바로가기
DataScience/Python

문자열로 이루어진 리스트를 피클로 저장할때

by leopard4 2022. 12. 15.

 

import pickle

# 저장할때 open("파일명", "wb") wb == 바이너리로 저장 
# dump(변수명, f)

with open("list.pickle","wb") as f:
    pickle.dump(flattened_list, f)
    
# 로드할때 open("경로명", "rb) rb == 리드 바이너리
with open("data/list.pickle", "rb") as f:
        flattened_list = pickle.load(f)