我对Python比较陌生,使用的是3.6.1版
我希望我可以用HMAC-SHA512为poloniex trading api编写python3.6.1post请求的代码,但是得到了这个错误。
我得到的答案大多来自python2,这不是我想要的。请帮忙。
我的python shell日志首先:{'command': 'returnBalances', 'nonce': 1492523610}
command=returnBalances&nonce=1492523610
Traceback (most recent call last):
File "C:/Users/draft/Desktop/test3.py", line 21, in
signing = hmac.new(secret, post_data, hashlib.sha512).hexdigest()
File "C:\Users\draft\AppData\Local\Programs\Python\Python36-32\lib\hmac.py", line 144, in new
return HMAC(key, msg, digestmod)
File "C:\Users\draft\AppData\Local\Programs\Python\Python36-32\lib\hmac.py", line 84, in __init__
self.update(msg)
File "C:\Users\draft\AppData\Local\Programs\Python\Python36-32\lib\hmac.py", line 93, in update
self.inner.update(msg)
TypeError: Unicode-objects must be encoded before hashing
接下来是我的完整代码:
^{pr2}$
希望有人能把我引向正确的方向。谢谢。