我有一个数字列表,我想从该列表中选择一个带有 random() 的随机数,以便我可以在循环函数中使用它,但是即使我写下所选的随机数是一个整数。
You should start by importing random .
So it should like something like this eg
import random
myList = ['a', 'b', 'c', 'd', 'e']
print(random.choice(myList))
Then it will print out a random number from your list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.