我希望这段代码不断地输出变量{actual,wb,pbactual,pbsim},这是我现在拥有的,但我希望wb和pbsim每次都是不同的值,因为现在它们每次都打印相同的列表,我希望它是随机的。顺便说一句,其他变量是我设置的,如果你需要它们,请让我知道!
Python
while win == False:
while run:
x = random.randint(1, rwb)
if x not in wb:
wb.append(x)
pbactual.sort()
if len(wb) == nwb2:
while npb2 > 0:
x = random.randint(1, rpb)
if x not in pbsim:
pbsim.append(x)
npb2 = npb2 - 1
run = False
print(actual, wb, pbactual, pbsim)变量
nwb = 5
nwb2 = 5
rwb = 10
npb = 2
npb2 = 2
rpb = 20
ballswin = 0
pbwin = 0
actual = []
wb = []
win = False
run = True发布于 2020-05-30 21:06:01
下面这样的代码应该能让你工作起来:
import time
random.seed(time.time())随机设置时间种子,每次都不同。
https://stackoverflow.com/questions/62102352
复制相似问题