python查询字符串参数

349次阅读
没有评论

python查询字符串参数

python字符串参数

自定义GET请求的一种常用方法是通过URL中的 查询字符串参数传递值。 要使用 get() 执行此操作,请将数据传递给 params。

查询字符串对于参数化GET请求很有用。 还可以通过添加或修改发送的请求的头部来自定义你的请求。

python字符串参数查询实例

可以使用GitHub的Search API来查找 requests 库:

import requests
 
# Search GitHub's repositories for requests
response = requests.get(
    'https://api.github.com/search/repositories',
    params={'q': 'requests+language:python'},
)
 
# Inspect some attributes of the `requests` repository
json_response = response.json()
repository = json_response['items'][0]
print(f'Repository name: {repository["name"]}')  # Python 3.6+
print(f'Repository description: {repository["description"]}')  # Python 3.6+
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-04-30发表,共计607字。
新手QQ群:570568346,欢迎进群讨论 Python51学习