Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save as json file in python

import json 
    
# python object(dictionary) to be dumped 
dict1 ={ 
    "emp1": { 
        "name": "Lisa", 
        "designation": "programmer", 
        "age": "34", 
        "salary": "54000"
    }, 
    "emp2": { 
        "name": "Elis", 
        "designation": "Trainee", 
        "age": "24", 
        "salary": "40000"
    }, 
} 
    
# the json file where the output must be stored 
out_file = open("myfile.json", "w") 
    
json.dump(dict1, out_file, indent = 6) 
    
out_file.close()
Comment

save as json file in python

import json 
    
# python object(dictionary) to be dumped 
dict1 ={ 
    "emp1": { 
        "name": "Lisa", 
        "designation": "programmer", 
        "age": "34", 
        "salary": "54000"
    }, 
    "emp2": { 
        "name": "Elis", 
        "designation": "Trainee", 
        "age": "24", 
        "salary": "40000"
    }, 
} 
    
# the json file where the output must be stored 
out_file = open("myfile.json", "w") 
    
json.dump(dict1, out_file, indent = 6) 
    
out_file.close()
Comment

how to save string json to json object python

# how to load a string to json
import ast
jsonobj = ast.literal_eval(str(hdf))
Comment

PREVIOUS NEXT
Code Example
Python :: unity python 
Python :: how to uninstall python 
Python :: pandas csv sum column 
Python :: BST_Deleting 
Python :: python 3 docs 
Python :: to_datetime with non zero padded values python 
Python :: python kubernetes client find pod with name 
Python :: sum of list of numbers 
Python :: python send image client 
Python :: python 3.7 download 
Python :: how to stop python for some time in python 
Python :: how to allow a range of numbers for example 1 to 14 on regular expression python 
Python :: encoding character or string to integer in python 
Python :: pyplot aera 
Python :: python3 conditional with boolean 
Python :: separate each characters by commas into a single characters separated by commas 
Python :: set lable of field django 
Python :: list vs dictionary python 
Python :: check if element is in list 
Python :: python for loop float increment 
Python :: query first 5 element in django 
Python :: Python - Comment lire une ligne de fichier par ligne 
Python :: color module python 
Python :: how to query DNS records using python 
Python :: plotly create plot 
Python :: repeat a condition n times one by one python 
Python :: Using python-poppler 
Python :: ascii values in python of 
Python :: python ip camera 
Python :: how to import something in python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =