Removing JSON property in array of objects

前端 未结 4 1296
鱼传尺愫
鱼传尺愫 2020-12-09 09:26

I have a JSON array that I\'m cleaning up in Python. I want to remove the imageData property:

data.json

[{\"title\": \"         


        
4条回答
  •  旧巷少年郎
    2020-12-09 10:15

    How about:
    clean_data = [k:v for k,v in data.iteritems() if k != 'imageData']

    Or a dictionary expresion/comprehension if you want a dictionary:
    clean_data = {k:v for k,v in data.iteritems() if k != 'imageData'}

提交回复
热议问题