ages = {'Tod':35, 'Jane':21, 'John': 27} for key in ages.keys(): print(key) # 'Tod', 'Jane', 'John' for value in ages.values(): print(value) # 35, 21, 27 for key in ages.keys(): print('{}의 나이는 {}입니다').format(key, ages[key]) for key in ages: print('{}의 나이는 {}입니다').format(key, ages[key]) # 위와 동일한 결과가 나온다
list의 enumerate 같은 기능을 하는 method이다
fruits = {'apple': 1, 'banana': 3, 'plum': 5} for fruit, numbers in fruits.items(): print('{}의 개수는 {}입니다').format(fruit, numbers)
AWS EC2에 pyenv로 python 설치하기 (0) | 2020.07.01 |
---|---|
Django - intro (0) | 2019.07.23 |
PIP와 Virtualenv (0) | 2019.07.22 |
자료구조 - dictionary (0) | 2019.07.21 |
모듈 만들기 (0) | 2019.07.21 |
댓글 영역