Answers for "how to access json file in python file and print key"

17

open json file python

import json

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

Reading JSON file in Python

import json
# For reading json file
with open ('fruit.json', 'r') as myfile:
 data=myfile.read()
# Parsing json code
fruit_detail = json.loads(data)
# Output
print ("fruit name: " + str(fruit_detail['fruit']))
print ("fruit size: " + str(fruit_detail['size']))
print ("fruit color: " + str(fruit_detail['color']))
Posted by: Guest on April-10-2022

Code answers related to "how to access json file in python file and print key"

Python Answers by Framework

Browse Popular Code Answers by Language