text=response.text.encode(response.encoding).decode('gbk')
print(text)
使用以上方式进行解码的时候,没有成功,报错:
经过大量打印测试,和资料查阅,我先查看response的编码方式是什么,然后使用这种编码方式对response.text进行编码,然后,使用gbk解码的时候,参数里加上了ignore,如下:
接下来,修改为下面的代码:
text1=response.text.encode('ISO-8859-1').decode('gbk','ignore')
print(text1)
成功解决!