Answer the question
In order to leave comments, you need to log in
list indices must be integers error. How to fix?
Through the request parse JSON from the site
"result":{"stats":[{"hi":"0.00","bye":"0.00","algo":9"},{"hi":"0.00","bye":"0.00","algo":8"},{"hi":"0.00","bye":"0.00","algo":7"}]}
r2 = requests.get('https://www..com/api?)
data = r2.json()
for i in data['result']['stats']:
x1 = data['result']['stats'][i]['hi']
z1 = data['result']['stats'][i]['bye']
bot.send_message(cid, str(x1) + str(z1))
Answer the question
In order to leave comments, you need to log in
First, split the lines of the form
Into several lines:
_x = data['result']
_x = _x['stats']
_x = _x[i]
x1 = _x['hi']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question