Python 官方文档:入门教程 => 点击学习
1.调用GitHub的公共api #需要提前安装requests 包 import requests url = 'https://api.github.com/search/repositories?q=language:pyth
#需要提前安装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'])
--结束END--
本文标题: Python 3.7之使用web api
本文链接: https://lsjlt.com/news/184430.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0