AttributeError: 'str' object has no attribute 'decode'

2019-10-28 张宇童 Python

python3下列代码会报上边的错

print("Response:", resp.text.decode('unicode_escape'))
解决办法:
print("Response:", resp.text.encode('utf-8').decode('unicode_escape'))
中间加上.encode('utf-8')即可

标签: python 学习笔记

发表评论:

Powered by emlog