The following code:
with open("J:\\python\\.data") as data:
self.data=pickle.load(data)
generated the following error:
File "J:\python\code.py", line 50, in get_events
self.data=pickle.load(data)
TypeError: 'str' does not support the buffer interface
I read that I might have to encode it, and I tried utf-8 and that didn’t work. What are the other formats? am I going in the right direction?
I forgot to mention that the object in .data is a list and was pickled using protocol 2. the var self.data is a list already
As noted in the
pickledocs:Thus you need to open it with mode
"rb"for binary.