获取页面内容时content转码 转码 转码 content返回的是bytes型也就是二进制的数据,要把它转为utf-8。 from django.test import Client c = Client() response = c.get('http://127.0.0.1:8000/hello/') response.content 结果: b'hello world!' str(response.content,'utf-8') #方法一 response.content.decode("utf-8") #方法二 结果: 'hello world!' 'hello world!'