gpt4 book ai didi

python - 字符串编码和解码?

转载 作者:IT老高 更新时间:2023-10-28 20:26:28 25 4
gpt4 key购买 nike

这是我对错误消息的尝试。我做错了什么?

string.decode("ascii", "ignore")

UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 37: ordinal not in range(128)

string.encode('utf-8', "ignore")

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 37: ordinal not in range(128)

最佳答案

您无法解码 unicode,也无法编码 str。试试看the other way around .

关于python - 字符串编码和解码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11339955/

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