import hmac, base64, hashlib, urllib2
base = 'https://.......'
def makereq(key, secret, path, data):
hash_data = path + chr(0) + data
secret = base64.b64decode(secret)
sha512 = hashlib.sha512
hmac = str(hmac.new(secret, hash_data, sha512))
header = {
'User-Agent': 'My-First-test',
'Rest-Key': key,
'Rest-Sign': base64.b64encode(hmac),
'Accept-encoding': 'GZIP',
'Content-Type': 'application/x-www-form-urlencoded'
}
return urllib2.Request(base + path, data, header)
错误:文件“ C:/Python27/btctest.py”,makereq中的第8行,hmac = str(hmac.new(secret,hash_data,sha512))UnboundLocalError:分配前已引用局部变量“ hmac”
有人知道为什么吗?谢谢
宝慕林4294392
相关分类