random.choice : 문자열, 리스트, 튜플과 같은 순서가 있는 반복개체에서 임의 요소를 리턴
# list
A = [1,2,3,4,5,6,7,8]
print(random.choice(A))
4
# Strings
A = '12345678'
print(random.choice(A))
3
# Tuple
A = (1,2,3,4,5,6,7,8)
print(random.choice(A))
6
random.shuffle : 순서 섞기
from random import shuffle
lst = [1,2,3]
shuffle(lst)
lst
[3, 1, 2]
'Python > Python Programming' 카테고리의 다른 글
[Python] Python Dictionary의 clear 메소드와 { } 차이 (0) | 2020.08.03 |
---|---|
Jupyter notebook 이미지 삽입하는 방법 (0) | 2020.07.22 |
[Python] for문에 리스트 순회시 remove가 정상적으로 반영되지 않는 이유 (0) | 2020.05.18 |
[Python] PC의 호스트네임(hostname)과 MAC Address 얻기 (0) | 2020.05.14 |
Jupyter notebook 간단한 사용법 (0) | 2020.03.07 |
[Python] Check the capacity of the mariadb table using pymysql (0) | 2020.02.06 |
[ Python ] 네이버_API 이용하기 (0) | 2020.01.21 |
[Python] BeautifulSoup의 find와 findAll의 차이 (0) | 2020.01.15 |