代码示例库
搜索、筛选并收藏你需要的 Python 代码片段。
#入门
#字符串
#数字
#列表
#列表
#循环
#切片
#if
#列表
#字典
#字典
#while
#while
#函数
#函数
#类
#类
#文件
#异常
#测试
#测试
#Pygame
#Pygame
#matplotlib
#随机漫步
#CSV
#API
#Django
#Django
#Django
requests请求GitHub API
第17章 使用API演示使用requests获取GitHub仓库数据。
import requests
url = "https://api.github.com/search/repositories"
params = {"q": "language:python", "sort": "stars", "order": "desc", "per_page": 10}
headers = {"Accept": "application/vnd.github.v3+json"}
r = requests.get(url, params=params, headers=headers)
print(f"状态码: {r.status_code}")
data =
...