如何正确获取数据?

时间:2020-04-12 19:21:12

标签: python api

嗨,我是python的新手,我在Mac上使用python 3。我不知道这是否相关。现在到问题。我需要通过api获取学校数据,但出现错误。 <module 'requests' from '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/__init__.py'>。有人可以解释一下这是什么意思

import requests
requests.get('https://api.github.com')
print(requests)

1 个答案:

答案 0 :(得分:1)

您正在打印模块requests,而不是请求的响应。 试试这个:

import requests
res = requests.get('https://api.github.com')
print(res.content)