시작하기무료로 시작하기

딕셔너리 반복(iterating)하기

JSON 데이터를 딕셔너리로 불러오면, Python의 내장 도구를 활용해 키와 값을 순회(iterate)할 수 있어요.

"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])
코드 편집 및 실행