xindzju
12/17/2018 - 12:08 PM

file_operation

python file operations

import json
data = {'name': 'charles'}
file_name = "file_name.json"
with open(file_name, 'w') as file_obj:
  json.dump(data, file_obj)  
import json 

file_name = "file_name.json"
with open(file_name) as file_obj:
  data = json.load(file_obj)
  print(data['name'])