使用pickle模块写入文件会导致错误
选择 | 换行 | 行号
- import pickle
- f = open("filepath/test.txt","w")
- f.write(" writing to a output file") # works
- pickle.dump([1,2,3],f) # fails with error "TypeError: write() argument must be str, not bytes"
- f.close()
pickle模块不是要解决在写入文件之前必须转换为字符串的问题吗?