Dan*_* G. 1 python random
我需要从数字中随机选择[1, 4, 7, 9, 13, 42].
[1, 4, 7, 9, 13, 42]
我不能使用,random.randint(1,42)因为它会给我一些中间的数字.如何仅从列表中的这些数字中进行选择?
random.randint(1,42)
mgi*_*son 10
你想要的random.choice.
random.choice
import random random.choice([1,4,7,9,13,42])
归档时间:
12 年,11 月 前
查看次数:
724 次
最近记录: