七禾页8 发表于 2020-10-25 08:08:15

学习笔记之随机数



x = random.getstate()
>>> print(x)

>>> random.randint(1,10)
6
>>> random.randint(1,10)
6
>>> random.randint(1,10)
10
>>> random.randint(1,10)
1
>>> random.randint(1,10)
4
>>> random.randint(1,10)
2
>>> random.randint(1,10)
5
>>> random.setstate(x)
>>> random.randint(1,10)
6
>>> random.randint(1,10)
6
>>> random.randint(1,10)
10
>>> random.randint(1,10)
1
>>> random.randint(1,10)
4
随机数的生成和状态再次重现






页: [1]
查看完整版本: 学习笔记之随机数