0
我試圖運行一個類似於在這個問題上的代碼:How do I sign a POST request using HMAC-SHA512 and the Python requests library?Python的請求,沒有屬性「體」
我有以下代碼:
import requests
import hmac
import hashlib
from itertools import count
import time
headers = { 'nonce': '',
'Key' : 'myKey',
'Sign': '',}
payload = { 'command': 'returnCompleteBalances',
'account': 'all'}
secret = 'mySecret'
NONCE_COUNTER = count(int(time.time() * 1000))
headers['nonce'] = next(NONCE_COUNTER)
request = requests.Request(
'POST', 'https://poloniex.com/tradingApi',
params=payload, headers=headers)
signature = hmac.new(secret, request.body, digestmod=hashlib.sha512)
request.headers['Sign'] = signature.hexdigest()
with requests.Session() as session:
response = session.send(request)
以下行:
signature = hmac.new(secret, request.body, digestmod=hashlib.sha512)
拋出這個錯誤:'請求' 對象有沒有屬性 '身體'
嘗試:request.content – Gui
,我收到了類似的錯誤:「請求」對象有沒有屬性「內容」 –
嘗試request.text –