반응형
파이썬에서 항목 목록을 "흔드는"좋은 방법이 있는지 궁금합니다. 예를 들어 [1,2,3,4,5]
는 [3,1,4,2,5]
(모든 순서가 동일하게 ).
해결 방법
from random import shuffle
list1 = [1,2,3,4,5]
shuffle(list1)
print list1
---> [3, 1, 2, 4, 5]
참조 페이지 https://stackoverflow.com/questions/34862378
반응형
'파이썬' 카테고리의 다른 글
파이썬 Can't install elementtree with pip (0) | 2020.11.11 |
---|---|
파이썬 10 초마다 Python 스크립트 실행 (0) | 2020.11.11 |
파이썬 Convert Z-score (Z-value, standard score) to p-value for normal distribution in Python (0) | 2020.11.11 |
파이썬 Checking whether a variable is an integer or not (0) | 2020.11.10 |
파이썬 Python 카운터 키 () 반환 값 (0) | 2020.11.10 |
댓글