본문 바로가기

L의 공간/Python

[Python] JSON 파일 읽고 쓰기

JSON 파일 생성
import json

status = {"hp":100, "attack":10, "full":100}

f = open("status.json", "w")
json.dump(status, f)
f.close()

 

JSON 파일 읽기
import json

f = open("status.json", "r")
status = json.load(f)
print(status)