UnboundLocalError: local variable … referenced before assignment

前端 未结 2 1764
时光说笑
时光说笑 2020-12-11 06:24
import hmac, base64, hashlib, urllib2
base = \'https://.......\'

def makereq(key, secret, path, data):
    hash_data = path + chr(0) + data
    secret = base64.b64d         


        
2条回答
  •  悲&欢浪女
    2020-12-11 06:44

    You are redefining the hmac variable within the function scope, so the global variable from the import statement isn't present within the function scope. Renaming the function-scope hmac variable should fix your problem.

提交回复
热议问题