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

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

大家好,我有这个代码:

data = data.split('&')

我收到以下错误:

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

如何拆分我的字符串?

data是一个bytes对象。您只能使用另一个 bytes 值来拆分它,您可以使用 bytes 文字(以 b 前缀开头)来创建一个:

data.split(b'&')