[英]Generating the same random number in Java and Python
如果給定相同的種子,是否有可能在 python 中生成與在 java 中相同的隨機數
以更准確的方式解釋,是否可以在 Python 中使用 Java 中的線性同余公式?
你看過這個項目嗎? http://pypi.python.org/pypi/java-random
使用Pyjnius :
from jnius import autoclass
rand = autoclass('java.util.Random')()
rand.setSeed(12345)
print(rand.nextInt(50))
print(rand.nextInt(50))
print(rand.nextInt(50))
print(rand.nextInt(50))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.