Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:58:52+00:00 2026-06-01T11:58:52+00:00

I have a process that pickles a dictionary using Python 3.2. I then need

  • 0

I have a process that pickles a dictionary using Python 3.2. I then need to unpickle this dictionary using Python 2.7 or 2.6. The problem is that when transferring between python versions I get a dictionary full of unicode data which upsets the Python API I am trying to feed it into.

Pickling in Python 3.2:

myDict = {'a': 'first', 'b': 'second', 'c': 'third'}
with open(file, 'wb') as f:
    pickle.dump(myDict, f, 2)

Unpickling in Python 2.6:

with open(file, f) as f:
    myDict = pickle.load(f)

returns: {u’a’: u’first’, u’c’: u’third’, u’b’: u’second’}

How can I get back exactly what I put in (i.e. not unicode)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:58:54+00:00Added an answer on June 1, 2026 at 11:58 am

    You’re actually getting back exactly what you put in, since strings in Python 3 are unicode

    To get str‘s, you can convert the keys and values in the dictionary:

    strDict = dict((k.encode(), v.encode()) for k, v in myDict.iteritems())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a process that I need to make into a service. This process
I have a process that I need to run almost permanently. I've being using
I have a process that spawns a helper process. Sometimes I need to debug
I have a process that imports a lot of data (950k rows) using inserts
I have parent process that opens child process . I need to perform some
I have a process that detects similar images using SURF and I want to
I have a process that parses an XML file using JDOM and xpath to
I have a process that get killed immediately after executing the program. This is
i have this process that is the heart of my app, that im creating,
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.