What is the issue with Python while processing my JSON file?

前端 未结 3 1818
余生分开走
余生分开走 2021-01-29 10:56

I have tried to remove the first key and value from a json file using python. While running the program, I came across error, they are mentioned as follows:

imp         


        
3条回答
  •  长情又很酷
    2021-01-29 11:46

    json_data is an instance of your file, not the content. so first apply read() on the instance for getting data. and second, write the full file name if you are reading a JSON file. your file should be testing.json. and third specify the mode of file opening mode. you can use this code

    import json
    with open('testing.json', 'r') as json_data:
        data = json.load(json_data.read())
        for element in data:
            del element['url']

提交回复
热议问题