import chardet
a='haha'
print(chardet.detect(a))
TypeError:bytes或bytearray类型的预期对象,得到:< class'str'>
我只需输入教程中的代码。 我真的无法弄清楚错误发生了什么。
答案 0 :(得分:2)
将字符串转换为字节...
变化:
$v=$env:BUILD_BUILDNUMBER
if($env:BUILD_SOURCEBRANCHNAME -ne "master")
{
$v="$v-rc"
}
Write-Host $v
Write-Host "##vso[task.setvariable variable=packageVersion;]$v"
Write-Host "##vso[build.updatebuildnumber]$v"
要:
a = 'haha'
答案 1 :(得分:1)
您也可以使用
a='haha'
print(chardet.detect(a.encode()))