random.choice(seq)

简介: random.choice(seq)
  1. random.choice(seq):从序列中随机选择一个元素
    例子:
import random
fruits = ["apple", "banana", "orange"]
fruit = random.choice(fruits)
print(fruit)


相关文章
|
8月前
|
数据采集 Python
【随手记】np.random.choice()函数
【随手记】np.random.choice()函数
197 0
|
9月前
|
Linux Windows
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
|
9月前
random.random()
random.random()
87 1
|
9月前
random.randint(a, b)
random.randint(a, b)
72 1
|
9月前
numpy.random.rand(d0, d1, …, dn)
numpy.random.rand(d0, d1, …, dn)
49 0
|
9月前
random.shuffle(lst)
random.shuffle(lst)
63 0
|
9月前
|
安全
secrets.choice(seq)
secrets.choice(seq)
47 0
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
|
Python
Python random 随机函数(random、uniform、randint、choice、choices、randrange、shuffle、sample)
Python random 随机函数(random、uniform、randint、choice、choices、randrange、shuffle、sample)
163 0

热门文章

最新文章