TypeError:类型集的对象不可JSON序列化

时间:2018-11-28 05:10:06

标签: python python-3.x algorithm bitmex

当我尝试在Python中运行此行时,使用Bitmex Rest API

qty2 = self.client.Position.Position_get(json.dumps({'symbol': 'XBTUSD'}),json.dumps({'currentQty'})).result()

我收到此错误

File "c:/Users/User2/sample_market_maker/SAMPLE/botv2.py", line 113, in place_orders
qty2 = self.client.Position.Position_get(json.dumps({'symbol': 'XBTUSD'}),json.dumps({'currentQty'})).result()
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '

TypeError: Object of type set is not JSON serializable

我见过How to JSON serialize sets?。它通过一个示例显示了类似的问题,但是我不确定如何在我的代码中实现它。

0 个答案:

没有答案