gpt4 book ai didi

python - 我使用 chardet 测试编码,但出现错误

转载 作者:行者123 更新时间:2023-12-05 01:33:03 25 4
gpt4 key购买 nike

import chardet 
a='haha'
print(chardet.detect(a))

TypeError: Expected object of type bytes or bytearray, got: < class 'str'>

我只是输入教程中的代码。我实在想不通到底出了什么问题。

最佳答案

要将字符串转换为字节...

变化:

a = 'haha'

收件人:

a = b'haha'

关于python - 我使用 chardet 测试编码,但出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50382685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com