gpt4 book ai didi

python - 故障排除引发 TypeError ("quote_from_bytes() expected bytes")

转载 作者:行者123 更新时间:2023-12-04 22:55:43 24 4
gpt4 key购买 nike

以下代码引发了我的错误

    def __to_canonical_querystring_post(self, params):
canonical_querystring = ""
# parameters have to be sorted alphabetically for the signing part
for param_key, param_value in sorted(params.items()):
if canonical_querystring != "":
canonical_querystring += "&"
canonical_querystring += param_key + "=" + urllib.parse.quote(param_value)
return canonical_querystring

参数是
Make_Payment_params = {
"debitAccountNumber": 12003189487,
"creditAccountNumber": 12065812627,
“金额”:100,
"requestedExecutionDate": "2019-03-09"
}

并且错误是 raise TypeError("quote_from_bytes() expected bytes")
类型错误:quote_from_bytes() 预期字节数

非常感谢帮助

最佳答案

urllib.parse.quote 的参数必须是字符串,但您的代码有时会传递整数。将调用更改为类似 urllib.parse.quote(str(param_value)) 的内容应该解决问题。

关于python - 故障排除引发 TypeError ("quote_from_bytes() expected bytes"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55078654/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com