Answers for "load json"

12

load json

import json

with open('data.txt') as json_file:
    data = json.load(json_file)
Posted by: Guest on March-02-2020
2

how to print a json file in python

# Python program to read 
# json file 
  
  
import json 
  
# Opening JSON file 
f = open('data.json',) 
  
# returns JSON object as  
# a dictionary 
data = json.load(f) 
  
# Iterating through the json 
# list 
for i in data['emp_details']: 
    print(i) 
  
# Closing file 
f.close()
Posted by: Guest on December-11-2020
0

json load python

import json

with open('jsonfile.json', 'r') as f:
	data = json.load(f)
Posted by: Guest on July-29-2021
1

json load

import json

with open('path_to_file/person.json') as f:
  data = json.load(f)
Posted by: Guest on October-27-2020
2

write json pythonb

>>> import json
>>> data = {'item': 'Beer', 'cost':'£4.00'}
>>> jstr = json.dumps(data, indent=4)
>>> print(jstr)
{
    "item": "Beer",
    "cost": "\u00a34.00"
}
Posted by: Guest on November-29-2019
0

json load

import json

with open('path_to_file/person.json') as f:
  data = json.load(f)

# Output: {'name': 'Bob', 'languages': ['English', 'Fench']}
print(data)
Posted by: Guest on October-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language