import chardet
a='haha'
print(chardet.detect(a))TypeError:类型为字节或字节数组的预期对象,got:< class 'str'>
我只是输入教程中的代码。我真搞不清到底出了什么错。
发布于 2018-05-17 04:49:54
将字符串转换为字节..。
更改:
a = 'haha'至:
a = b'haha'发布于 2020-07-15 02:19:06
您也可以使用
a='haha'
print(chardet.detect(a.encode()))https://stackoverflow.com/questions/50382685
复制相似问题