类型错误:“str”不支持缓冲区接口 - python
我目前正在做一个在线 Python 谜题系列,我遇到了一个需要卸载 pickled 文件的问题。我阅读了有关它的文档,但我不断收到
TypeError: 'str' does not support the buffer interface
...所以我在 Google 上搜索并找到了一个具有类似问题的问题。答案指向 http://wiki.python.org/moin/UsingPickle 。
我尝试了示例中的代码,但遇到了同样的问题?我正在使用Python 3.2.2。搞什么??
完整回溯:
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
从这里的示例: http://wiki.python.org/moin/UsingPickle
我已经使用教程中的第一个代码示例成功创建了 save.p 文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以二进制模式打开 pickle 文件:
favorite_color = pickle.load(open("save.p", "rb"))
。Open the pickle file in binary mode:
favorite_color = pickle.load(open("save.p", "rb"))
.