Created
February 1, 2022 09:14
-
-
Save Keycatowo/e36c57773bcba9ac3b750307c2dbe388 to your computer and use it in GitHub Desktop.
讀寫pickle檔案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 讀寫pickle檔案 | |
import pickle | |
# save | |
with open('example.pkl', 'wb') as f: | |
# 記得是用dump不是save | |
pickle.dump(file=f, obj=data) # file:檔案handle, obj:變數名稱 | |
# read | |
with open('example.pkl', 'rb') as f: | |
data = pickle.load(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment