6

I'm currently doing an online Python puzzle series, and I've gotten to a problem where you need to unload a pickled file. I read the documentation on it, but I kept getting

TypeError: 'str' does not support the buffer interface

...so I search on Google and arrive at a question on SO with a similar problem. The answer points to http://wiki.python.org/moin/UsingPickle .

I tried the code in the example and I'm getting the same problem? I'm using Python 3.2.2. WTF??

Complete Traceback :

Traceback (most recent call last):
  File "C:\foo.py", line 11, in <module>
    test1()
  File "C:\foo.py", line 9, in test1
    favorite_color = pickle.load( open( "save.p" ) )
TypeError: 'str' does not support the buffer interface

From the example here: http://wiki.python.org/moin/UsingPickle

I have already successfully created the save.p file with the first code example in the tutorial.

4
  • 1
    Probably python 2 vs python 3 difference. Can you post a complete traceback? Commented Oct 1, 2011 at 3:26
  • 1
    I was just clicking the first Google links. I wasn't aware that not only was I reading Python 2 stuff, but that Python 2 and 3 have MAJOR differences... Anyway, where do I find Python 3 stuff? Commented Oct 1, 2011 at 3:35
  • Also, that's not my previous question. Commented Oct 1, 2011 at 3:35
  • Sorry... wrong link. In my answer to your previous question, I linked to "Dive into Python 3". That's well worth a read. The majority of information out there still refers to Python 2. Commented Oct 1, 2011 at 4:15

1 Answer 1

14

Open the pickle file in binary mode: favorite_color = pickle.load(open("save.p", "rb")).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.