TypeError:访问python时出现无效的非字符串序列或映射对象错误

2024-04-24 13:04:03 发布

您现在位置:Python中文网/ 问答频道 /正文

     return json.loads(ret.read())
    else:
        req['command'] = command
        req['nonce'] = int(time.time()*1000)
        post_data=urllib.parse.urlencode('utf-8')

        sign = hmac.new(self.Secret, post_data, hashlib.sha512).hexdigest()
        headers = {
            ("sign"): sign,
            ("key"): self.APIKey
        }

        headers = headers.encode('utf-8')
        ret = urllib.parse.urlencode('https://poloniex.com/tradingApi', post_data, headers)

        ret = urllib.request.urlopen()
        jsonRet = json.loads(ret.read())
        return self.post_process(jsonRet)

这是连接到poloniex exchange的python代码,用于自动加密交易。说到这部分我就有麻烦了。这段代码是在python2上编写的,然后我尝试将其转换为python3。在


Tags: selfjsonreaddatareturntimeparseurllib