转码
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!'