Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'str' does not support the buffer interface

Tags:

python

i post from my original code,

crystal = open('vmises.dat','r')
crystalincrement  = pickle.load(crystal)
crystaldir = pickle.load(crystal)
crystalface = pickle.load(crystal)
crystal.close()

Error is,

crystalincrement  = pickle.load(crystal)

TypeError: 'str' does not support the buffer interface

i use python V 3.2

like image 972
coolcing Avatar asked Aug 11 '11 19:08

coolcing


2 Answers

The real answer should be open the file in binary mode in windows. open('data.txt', 'rb')

like image 162
Jingshao Chen Avatar answered Sep 19 '22 17:09

Jingshao Chen


The question was edited after I originally posted this and it was accepted. The answer to the updated question is to open the file in binary mode:

crystal = open('vmises.dat', 'rb')

Answer to original, pre-edit question:

Well, data is a string. The object you need to work on is a.

a = open('data.txt','r')
b = pickle.load(a) 
c = pickle.load(a)
d = pickle.load(a)
a.close()

For pickle info, see the Python Wiki or Python for Kids.

like image 37
agf Avatar answered Sep 19 '22 17:09

agf