Answer the question
In order to leave comments, you need to log in
TypeError: list indices must be integers or slices, not str in JSON?
And so, with the help
[item for item in data['data']['list'] if item['user']['name'] == 'name1']
I filter the code and leave only the code where name == name1 (which is clear from the code), how can I return this code back to JSON and filter it again? TypeError: list indices must be integers or slices, not str
using code like this:[item for item in njson['data']['list'] if 'text' in item['message']]
tell me what to do
Answer the question
In order to leave comments, you need to log in
It is logical that if
njson = [item for item in data['data']['list'] if item['user']['name'] == 'name1']
data['data']['list'] = [item for item in data['data']['list'] if item['user']['name'] == 'name1']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question