Answers for "reading writing json file"

7

json load from file python 3

import json

with open('file_to_load.json', 'r') as file:
  data = json.load(file)
Posted by: Guest on May-07-2020
11

write json pythonb

import json

data = {}
data['people'] = []
data['people'].append({
    'name': 'Scott',
    'website': 'stackabuse.com',
    'from': 'Nebraska'
})
data['people'].append({
    'name': 'Larry',
    'website': 'google.com',
    'from': 'Michigan'
})
data['people'].append({
    'name': 'Tim',
    'website': 'apple.com',
    'from': 'Alabama'
})

with open('data.txt', 'w') as outfile:
    json.dump(data, outfile)
Posted by: Guest on November-29-2019

Code answers related to "reading writing json file"

Code answers related to "Javascript"

Browse Popular Code Answers by Language