user277465
user277465

Reputation:

Python3.0 TypeError

Usually one comes across this problem in python3.0 while attempting a split() method on a bytes type object.

TypeError: Type str does'nt support the buffer API

This issue can be resolved by using the split method after decoding the bytes type object.

However, I find the error message rather ambiguous. Am I missing some underlying concept or do you think the message is ambiguous too?(If more people think so, maybe we could ask for a fix)

Upvotes: 4

Views: 372

Answers (1)

Alex Martelli
Alex Martelli

Reputation: 881457

Just forget the existence of totally-obsolete, zero-reasons-to-keep-it-around 3.0, upgrade to 3.1 instead, and splitting bytes is just fine:

>>> x = bytes(b'ciao bella')
>>> x.split()
[b'ciao', b'bella']

Upvotes: 9

Related Questions