프로그래밍 문법/python

[파이썬] 2차원리스트 dictionary형으로 바꾸기

씩씩한 IT블로그 2020. 6. 19. 21:23
반응형

2차원으로 구성된 자료형은 dictionary형으로 바꿀 수 있다.

L1=[[1,2],[54,5]]
L2=[(3,5),(6,7)]
L3=([1,2],(7,8))

tempD1=dict(L1)
tempD2=dict(L2)
tempD3=dict(L3)

print(tempD1)
print(tempD2)
print(tempD3)

 

<output>

더보기

{1: 2, 54: 5}

{3: 5, 6: 7}

{1: 2, 7: 8}

반응형