以下代码段引发了错误
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” }
,并且引发错误TypeError(“ quote_from_bytes()预期的字节”) TypeError:quote_from_bytes()预期的字节数
非常感谢帮助
答案 0 :(得分:3)
urllib.parse.quote
的参数必须是字符串,但是您的代码有时会传递整数。将呼叫更改为urllib.parse.quote(str(param_value))
之类的问题应该可以解决此问题。