【原】Python 用例:二進制寫入和讀取文件內容
import pickle as p shoplistfile='shoplist.data' shoplist=['apple','carrot'] # because the dump operation is using binary, so 'b' is needed. # also for read file. f=open(shoplistfile,'wb') p.dump(shoplist,f) f.close del shoplist f=open(shoplistfile,'rb') storedlist=p.load(f) print(storedlist)
1.二進制文件,用NotePad++打開亂碼
2.讀取內容后,打印:



浙公網安備 33010602011771號