user2950593
user2950593

Reputation: 9627

TypeError: Type str doesn't support the buffer API when splitting string

Hi all I have this code:

data = data.split('&')

And I get the following error:

data = data.split('&') TypeError: Type str doesn't support the buffer API

How to split my string?

Upvotes: 9

Views: 11784

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1122382

datais a bytes object. You can only use another bytes value to split it, you can use a bytes literal (starting with the b prefix) to create one:

data.split(b'&')

Upvotes: 22

Related Questions