프로그래밍 문법/python

json파일 읽고 쓰기

씩씩한 IT블로그 2020. 8. 13. 15:12
반응형

1. 쓰기

import json

resp_json=(딕셔너리자료형)
with open('./파일이름','w') as outfile:
    json.dump(resp_json,outfile)

 

2. 읽기

import json

file_path='파일경로'
with open(file_path, "r") as json_file:
    json_data = json.load(json_file)
    

# json_data는 딕셔너리 자료형
반응형