473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Using pickle module to write to file gives error

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
0 1226

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

Similar topics

0
by: dataangel | last post by:
For the project I'm working on right now I'm dealing with a lot of class objects that I plan to be changing at run-time through the get/has/setattr functions. I'm wondering whether or not the...
0
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try...
4
by: rach | last post by:
I just started to learn C++. I copied the following code from a data structure textbook to a ".h" file and couldn't compile it. The code contains three template interfaces. One inherits another. The...
2
by: Najeemudheen | last post by:
Hai guys, Is there anybody who can help me solve this problem. Problem: i compiled and generated a delphi prg (which uses a wrapper for gdiplus) which i was able to install on the...
1
by: Gabriel Genellina | last post by:
En Sun, 18 May 2008 00:14:19 -0300, Guillaume Bog <guibog@gmail.comescribió: A shelve is just a persistent dictionary that uses pickle to store the objects. If you want to store one or a few...
2
by: Nagu | last post by:
I am trying to save a dictionary of size 65000X50 to a local file and I get the memory error problem. How do I go about resolving this? Is there way to partition the pickle object and combine...
0
by: Nagu | last post by:
I am trying to save a dictionary of size 65000X50 to a local file and I get the memory error problem. How do I go about resolving this? Is there way to partition the pickle object and combine...
1
by: Nagu | last post by:
I didn't have the problem with dumping as a string. When I tried to save this object to a file, memory error pops up. I am sorry for the mention of size for a dictionary. What I meant by...
3
omerbutt
by: omerbutt | last post by:
hi i have written a query and it is giving me th following error here is my query , any suggesstions $q="SELECT * FROM ".PRODUCT." P , ".PRODUCT_DESCRIPTION." PD WHERE
3
by: rahulsankhe1089 | last post by:
i have created web application in asp.net using visual studio 2010. i did coding in vb.net. in vb.net code i used simple message box. it does not give error when i run project through visual...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.