[英]Query params for nested objects with python requests module like QS.stringify
在 Python 使用请求模块创建 Strapi 客户端时,我遇到了一个问题。
当使用带有嵌套字典的requests.get
方法的 params 参数时,它不会像 npm package qs
那样转换为查询字符串。
我想要qs.stringify
中的 qs.stringify,但在 Stack Overflow 上找不到答案。
我找到了这个 package: https://github.com/cine-io/nested-query-string
def _get(self, path, params=None, **kwargs):
url = self.__construct_url(path)
headers = self.__get_request_headers()
if params is not None:
#see line here!!
from nested_query_string import NestedQueryString
params = NestedQueryString.encode(params)
response = requests.get(url, params=params, headers=headers, **kwargs)
assert response.status_code == 200
return self.__parse_strapi_response(response)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.