By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Using pickle module to write to file gives error

P: 1
Expand|Select|Wrap|Line Numbers
  1. import pickle
  2. f = open("filepath/test.txt","w")
  3. f.write(" writing to a output file") # works
  4. pickle.dump([1,2,3],f) # fails with error "TypeError: write() argument must be str, not bytes"
  5. f.close()
Is pickle module not meant to overcome the issue of having to convert to string before writing to a file?
Aug 4 '17 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.