Python Programming - Reading and Writing Files - Discussion

Discussion Forum : Reading and Writing Files - General Questions (Q.No. 95)
95.
How can you write a dictionary to a JSON file named "data.json"?
with open("data.json", "w") as file:
    json.dump(my_dict, file)
write_json("data.json", my_dict)
with open("data.json", "w") as file:
    file.write(json.dumps(my_dict))
write_to_json("data.json", my_dict)
Answer: Option
Explanation:
Using json.dump() to write a dictionary to a JSON file.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.