[英]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.