我正在尝试做一些分析,出于“原因”,我希望我的程序中的对象每个都有自己的种子,但没有全局种子。我能完成这样的事情吗?在
a = random.seed(seed1)
b = random.seed(seed1)
for a in range(5) :
print a.random(), b.random()
预期输出将是
^{pr2}$
等等。。。
显然,这是一个超级人工的例子——这些单独的种子将被埋藏在对象中,并与特定的事物相对应。但第一步是让这样的东西发挥作用。在
如何让python维护多种子随机数?在
Tags:
您需要使用
random.Random
类对象。在documentation明确说明了您的问题:
那么,这可能有助于您:
输出为:
38 38
98 98个
8 8
29 29日
67 67
我希望您只是在寻找上述输出中提到的随机数:
这里有一些代码。如果对您有帮助,请检查:
输出如下:
1493年
51 62岁
2012年
9 3个
52 71
相关问题 更多 >
编程相关推荐