-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
startswith first arg must be bytes or a tuple of bytes, not str #33
Comments
Python 3.6.2 |
把数据使用 smart_bytes 转码一下试试? |
找到问题了 def params_encoding(params, charset='utf-8'):
newparams = {}
for k, v in params.items():
newparams[k] = smart_unicode(v)
return newparams 这里key还是byte的,所以后面xmltodict 匹配attitude的时候 key startwith('@')的时候出错了 。。 |
python3字符串处理逻辑和python2不太一样,改成: newparams[k.decode("utf-8")] = smart_unicode(v) 就好了。 |
签名拼字符串的地方也要改一下: |
感谢 反馈 我测试一下加进去 |
同遇到该问题 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
支付调用统一支付接口的时候,我基本上只填了最基本的信息 ,不知道哪里出的问题。
File "/Users/ ** /lib/python3.6/site-packages/weixin/pay.py", line 464, in unifiedorder
method, url, kwargs = self.prepare_request('POST', path, params)
File "/Users/ ** /lib/python3.6/site-packages/weixin/pay.py", line 115, in prepare_request
kwargs['data'] = smart_bytes(xmltodict.unparse(xml_dict))
File "/Users/ ** /lib/python3.6/site-packages/xmltodict.py", line 449, in unparse
**kwargs)
File "/Users/ ** /lib/python3.6/site-packages/xmltodict.py", line 386, in _emit
if ik.startswith(attr_prefix):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
The text was updated successfully, but these errors were encountered: