"Dictionary to list"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 4개는 보이지 않습니다)
2번째 줄: 2번째 줄:


==Python==
==Python==
{{참고|파이썬 딕셔너리를 리스트로 변환}}
[[category: Python]]
[[category: Python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
dct = {'b': 4, 1: 8, 'a': 2}
dct = {'b': 4, 1: 8, 'a': 2}
lst = list(dct)
lst = list(dct)
print( lst )
print( lst )
# [1, 'a', 'b']
# [1, 'a', 'b']
</source>
</syntaxhighlight>
<syntaxhighlight lang='Python'>
dct = {'b': 4, 1: 8, 'a': 2}
print(list( zip(dct.keys(), dct.values()) ))
# [('a', 2), (1, 8), ('b', 4)]
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[list to dictionary]]
*[[list to dictionary]]
*[[dictionary to set]]
*[[dictionary to set]]
*[[dictionary to list]]
*[[dictionary to tuple]]
*[[zip]]

2020년 11월 2일 (월) 02:31 기준 최신판

dictionary to list

1 Python[ | ]

dct = {'b': 4, 1: 8, 'a': 2}
lst = list(dct)
print( lst )
# [1, 'a', 'b']
dct = {'b': 4, 1: 8, 'a': 2}
print(list( zip(dct.keys(), dct.values()) ))
# [('a', 2), (1, 8), ('b', 4)]

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}