시작하기무료로 시작하기

딕셔너리 반복 처리하기

JSON 데이터를 딕셔너리로 불러오면, Python의 내장 도구를 활용해 키와 값을 반복 처리할 수 있습니다.

"nested_school_scores.json" 파일은 raw_testing_scores 변수에 딕셔너리 형태로 저장되어 있으며, 다음과 같은 구조를 가지고 있습니다:

{
    "01M539": {
        "street_address": "111 Columbia Street",
        "city": "Manhattan",
        "scores": {
              "math": 657,
              "reading": 601,
              "writing": 601
        }
  }, ...
}

이 연습은 강의의 일부입니다

Python으로 하는 ETL과 ELT

강의 보기

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

raw_testing_scores_keys = []

# Iterate through the keys of the raw_testing_scores dictionary
for school_id in raw_testing_scores.____():
  	# Append each key to the raw_testing_scores_keys list
	raw_testing_scores_keys.append(____)
    
print(raw_testing_scores_keys[0:3])
코드 편집 및 실행