美文网首页
Python 中文乱码问题

Python 中文乱码问题

作者: 马卡他弟本来是我的昵称 | 来源:发表于2020-06-15 10:05 被阅读0次

    问题

    requests 返回的数据中,中文出现乱码

    image
    decode 报错,
    AttributeError: 'str' object has no attribute 'decode'
    

    encode 也无法解码显示正确的字符。

    解决

    req = requests.get(url, headers=headers)
    html=req.content
    html_doc=str(html,'utf-8')
    

    相关文章

      网友评论

          本文标题:Python 中文乱码问题

          本文链接:https://www.haomeiwen.com/subject/ayhcxktx.html