Using pickle module to write to file gives error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ckpkhill
    New Member
    • Aug 2017
    • 1

    Using pickle module to write to file gives error

    Code:
    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()
    Is pickle module not meant to overcome the issue of having to convert to string before writing to a file?
Working...