发布时间:2019-07-29 10:28:41编辑:auto阅读(1444)
#需要提前安装requests 包
import requests
url = 'https://api.github.com/search/repositories?q=language:python&sort=stars'
r = requests.get(url)
print("Status code:",r.status_code)
response_dict = r.json()
print(response_dict.keys())
print("Total repositories:",response_dict['total_count'])
#探索有关GitHub仓库的信息
repo_dicts = response_dict['items']
print("Repositories returned:",len(repo_dicts))
#研究第一个GitHub仓库
repo_dict = repo_dicts[0]
print("\nkeys:",len(repo_dict))
for key in sorted(repo_dict.keys()):
print(key)
print("\nSelected information about first repository:")
print('Name:',repo_dict['name'])
print('Owner:',repo_dict['owner']['login'])
上一篇: python3基础:文件操作
下一篇: 在Python中使用protocol b
47490
45792
36789
34321
28958
25594
24441
19608
19109
17630
5463°
6046°
5568°
5636°
6571°
5374°
5375°
5882°
5853°
7167°