# requests如何查看响应内容?




```text``` 方法会拿到请求的响应内容，比如以再github的timeline接口为例

```
>>> import requests

>>> r = requests.get('https://api.github.com/events')
>>> r.text
u'[{"repository":{"open_issues":0,"url":"https://github.com/...
```

Requests会自动去解码server端返回的内容，大部分的unicode字符集都会被无缝解码。

当你发送请求的时候，Requests会根据HTTP headers来推断编码，并在```r.text```调用的时候使用。我们可以查看和修改Requests的编码，比如

```
>>> r.encoding
'utf-8'
>>> r.encoding = 'ISO-8859-1'
```




原始封面

![课程图片](https://images.unsplash.com/photo-1488998527040-85054a85150e?w=300)


