This is a question to remove a specific key (name) from the data received by python json

Asked 2 years ago, Updated 2 years ago, 44 views

// Enter your code here
url = "https://8oi9s0nnth.apigw.ntruss.com/corona19-masks/v1/storesByAddr/json"
jdata = jdata['stores']

I want to show the dictionary corresponding to stores and delete and show certain keys and values.

ex) I tried code to remove key values like del(dic['lat']) but I don't think it works.

I'm a beginner studying Python. I want to spray it on the screen through Python Django, but I can't try it, so I'm asking you this question

python django

2022-09-20 22:12

1 Answers

import json
import requests
r = requests.get('https://8oi9s0nnth.apigw.ntruss.com/corona19-masks/v1/storesByAddr/json')
data = r.json()

for idx, i in enumerate(data['stores']):
    dict = i
    del(dict['code'], dict['created_at'])
    data['stores'][idx] = dict

I've done it like this, but I think there might be another good way.


2022-09-20 22:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.