Answer the question
In order to leave comments, you need to log in
Parsing JSON in Python. How to get specific data?
There is json
{"result":{"stats":[{"profitability_above_ltc":"41.61","price":"0.0282","profitability_ltc":"0.0199","algo":0,"speed":"243.45559900"},{"price":"0.6757","profitability_btc":"0.5956","profitability_above_btc":"13.44","algo":1,"speed":"18171866.00000000"},{"profitability_above_ltc":"-100.00","price":"0.0000","profitability_ltc":"0.0199","algo":2,"speed":"0.00000000"},{"profitability_above_ltc":"567.12","price":"0.0089","profitability_ltc":"0.0199","algo":3,"speed":"563.12656201"},{"profitability_above_ltc":"148.13","price":"0.0076","profitability_ltc":"0.0199","algo":4,"speed":"0.13909400"},{"profitability_above_ltc":"1558.07","price":"0.0007","profitability_ltc":"0.0199","algo":5,"speed":"15.08137400"},{"profitability_above_ltc":"-37.04","price":"0.0025","profitability_ltc":"0.0199","algo":6,"speed":"0.94719039"},{"profitability_above_ltc":"1172.32","price":"0.0181","profitability_ltc":"0.0199","algo":7,"speed":"0.00532400"},{"profitability_above_ltc":"2211.17","price":"1.0237","profitability_ltc":"0.0199","algo":8,"speed":"0.02628506"},{"profitability_above_ltc":"982.62","price":"0.1233","profitability_ltc":"0.0199","algo":9,"speed":"0.61854782"},{"profitability_above_ltc":"-100.00","price":"0.0000","profitability_ltc":"0.0199","algo":10,"speed":"0.00000000"},{"profitability_above_ltc":"478.74","price":"0.0072","profitability_ltc":"0.0199","algo":11,"speed":"1.01352300"},{"profitability_above_ltc":"731.45","price":"0.0079","profitability_ltc":"0.0199","algo":12,"speed":"15.98064700"},{"profitability_above_ltc":"-100.00","price":"0.0000","profitability_ltc":"0.0199","algo":13,"speed":"0.00000000"},{"profitability_above_ltc":"3304.89","price":"0.0399","profitability_ltc":"0.0199","algo":14,"speed":"73.06248541"},{"profitability_above_ltc":"-100.00","price":"0.0000","profitability_ltc":"0.0199","algo":15,"speed":"0.00000000"},{"profitability_above_ltc":"3411.79","price":"0.0002","profitability_ltc":"0.0199","algo":16,"speed":"0.00000000"},{"profitability_above_ltc":"-100.00","price":"0.0000","profitability_ltc":"0.0199","algo":17,"speed":"0.00000000"},{"profitability_above_ltc":"879604.26","price":"0.0501","profitability_ltc":"0.0199","algo":18,"speed":"0.00000000"},{"profitability_above_ltc":"-100.00","price":"0.0002","profitability_ltc":"0.0199","algo":19,"speed":"0.00002661"},{"price":"0.0353","algo":20,"speed":"250.11615500","profitability_eth":"0.0303","profitability_above_eth":"16.42"},{"profitability_above_ltc":"3451536.43","price":"0.3621","profitability_ltc":"0.0199","algo":21,"speed":"1579.02181414"},{"profitability_above_ltc":"-100.00","price":"1.1503","profitability_ltc":"0.0199","algo":22,"speed":"0.00463899"},{"profitability_above_ltc":"-100.00","price":"4.1517","profitability_ltc":"0.0199","algo":23,"speed":"15.87700000"},{"profitability_above_ltc":"-100.00","price":"0.0030","profitability_ltc":"0.0199","algo":24,"speed":"0.00643681"},{"profitability_above_ltc":"-100.00","price":"1.2520","profitability_ltc":"0.0199","algo":25,"speed":"1104.98494638"}]},"method":"stats.global.current"}
Answer the question
In order to leave comments, you need to log in
>>> import json
>>> a = json.loads('ваша строка')
>>> res = filter(lambda x: x['algo']==20, a['result']['stats'])
>>> res
[{u'profitability_above_eth': u'16.42', u'price': u'0.0353', u'speed': u'250.11615500', u'algo': 20, u'profitability_eth': u'0.0303'}]
>>> res[0]['algo']
20
>>> res[0]['speed']
u'250.11615500'
>>> res[0]['price']
u'0.0353'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question