Answers for "python json file read and write"

1

write json to file python

# to write on file
# data_dict is a dictionary

import json
        
with open('data.json', 'w') as f:
	json.dump(data_dict, f)
Posted by: Guest on January-27-2021
0

write json file python

# Python program to write JSON
# to a file
  
  
import json
  
# Data to be written
dictionary ={
    "name" : "sathiyajith",
    "rollno" : 56,
    "cgpa" : 8.6,
    "phonenumber" : "9976770500"
}
  
# Serializing json 
json_object = json.dumps(dictionary, indent = 4)
  
# Writing to sample.json
with open("sample.json", "w") as outfile:
    outfile.write(json_object)
Posted by: Guest on March-01-2022

Code answers related to "python json file read and write"

Code answers related to "Javascript"

Browse Popular Code Answers by Language