[英]Python3.0 TypeError
Usually one comes across this problem in python3.0 while attempting a split() method on a bytes type object. 通常在python3.0中遇到这个问题,同时在字节类型对象上尝试split()方法。
TypeError: Type str does'nt support the buffer API
TypeError:类型str不支持缓冲区API
This issue can be resolved by using the split method after decoding the bytes type object. 解码字节类型对象后,可以使用split方法解决此问题。
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)
我是否遗漏了一些潜在的概念,或者您认为该消息是否含糊不清?(如果更多人这么认为,也许我们可以要求修复)
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: 只是忘记存在完全过时的,零原因保持它的3.0,而不是升级到3.1,并且拆分字节就好了:
>>> x = bytes(b'ciao bella')
>>> x.split()
[b'ciao', b'bella']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.