파이썬 읽기 json 파일
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
json 파일 python 에서 데이터 추출
import json
# with json load (file)
info = open('data.json',)
res = json.load(info)
print(res)
print("Datatype after deserialization : " + str(type(res)))
#>>> {'name': 'Dave', 'City': 'NY'}
#>>> Datatype of the serialized JSON data : <class 'dict'>
파이썬을 사용하여 json 에서 특정 데이터를 얻는 방법
with open('distros.json', 'r') as f:
distros_dict = json.load(f)
for distro in distros_dict:
print(distro['Name'])