DS/fast campus daily report
6.27 (데이터엔지니어링) dictionary, set
eagle9898
2020. 6. 27. 21:24
Dictionary, Set (20:26)
- 키와 값을 갖는 데이터 구조
- 키는 hash 값으로 저장
- 순서X, index X
# List, 원소의 index를 안다고 하면 접근 시간은 0
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
print(a[0])
# dictionary
b = {'korea':'seoul','canada':'ottawa','usa':'washington d.c'}
print(b)
print( b['korea'])
#dic2
c = {1:0.1,2:0.2, 'japan':None}
print( c[1] )
#dic3
c['japan']='tokyo'
print( c ) # c list의 2번째 항목이 아니라, c dictionary의 key 1 의 value return
update() 함수
- 두 개의 dictionary를 병합한다
key 삭제
- del 키워드 사용
- pop 함수 이용
clear
dictionary의 모든 값 초기화