파이썬 코딩 도장 12.1 딕셔너리 만들기
방법 1 : 키=값 형식
lux1 = dict(health=490, mana=334, melee=550, armor=18.72)
방법 2 : zip() 사용
lux2 = dict(zip(['health', 'mana', 'melee', 'armor'], [490, 334, 550, 18.72]))
방법 3 : (키, 값) 형식의 튜플 만들기
lux3 = dict([('health', 490), ('mana', 334), ('melee', 550), ('armor', 18.72)])
방법 4 : {} 사용
lux4 = dict({'health' : 490, 'mana' : 334, 'melee' : 550, 'armor' : 18.72})
zip 함수 사용하는게 가장 있어보인다.
'배운 것 > Python' 카테고리의 다른 글
| [pandas] 기존 데이터 프레임에서 열(column)을 삭제한 후, 새로운 데이터 프레임으로 저장하기 (0) | 2021.09.14 |
|---|---|
| [pandas] DataFrame loc[ ] 연산자 - Index(인덱스) (0) | 2021.07.20 |
| [pandas] get_dummies : One-hot encoding(원핫 인코딩) (0) | 2021.07.20 |
| [numpy] numpy.select(conditionlist, choicelist, default=) (0) | 2021.07.20 |
| [기초 문법] input().split() (0) | 2021.03.31 |