json výpis do souboru
import json
data = {"key": "value"}
with open('data.json', 'w') as jsonfile:
json.dump(data, jsonfile)
python json uložit do souboru
with open('output.json', 'w') as outfile:
json.dump(data, outfile)
json zatížení ze souboru python 3
import json
with open('file_to_load.json', 'r') as file:
data = json.load(file)
napište 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)
uložit json soubor python
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
Python json výpis do souboru
import json
with open('data.json', 'w') as f:
json.dump(data, f)