我试图在安装了不同python3版本的不同系统上从python的random.random()中复制一个随机序列。在Most of the random module’s algorithms and seeding functions are
subject to change across Python versions, but two aspects are
guaranteed not to change:If a new seeding method is added, then a backward compatible seeder
will be offered.
The generator’s random() method will continue to
produce the same sequence when the compatible seeder is given the same
seed.
因此,我希望下面的代码总是打印相同的10个数字,不管具体的python3版本是什么:import sys
print(sys.version)
from random import seed, random
seed(str(1))
for i in range(10):
print(random())
但是,在两台不同的机器上进行测试:
^{pr2}$
以及3.1.2 (release31-maint, Dec 9 2011, 20:59:40)
[GCC 4.4.5]
0.0698436845523
0.27772471476
0.833036057868
0.35569897036
0.36366158783
0.722487971761
0.963133581734
0.263723867191
0.451002768569
0.0998765577881
给出不同的结果。在
为什么会这样?有没有什么方法可以让它起作用(也就是说,得到相同的随机序列两次?)在