我可以使用python生成真实的随机数吗?

编程入门 行业动态 更新时间:2024-10-25 10:27:24
本文介绍了我可以使用python生成真实的随机数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在学习python的随机模块.而且我知道它会生成伪随机数.它的核心思想是使用高频时钟作为种子,然后使用一个函数产生一个看起来像随机数".

I'm learning random module of python. And I know it generates pseudo random number. Which its core idea is to use a high-frequency clock as a seed and then use a function to produce a 'looking-like random number.

据我所知,在现实世界中甚至不可能生成真实的随机数.

As I know it's even impossible to produce authentic random number in the real world.

但是我知道Unix随机产生器引入了其他一些因素,例如鼠标移动轨迹的参数,IO响应时间,以为其随机数产生器函数引入不确定性.通过该方法,我们可以获得比普通伪随机数更好的随机数.很难预测.

But I know Unix random producer has introduced some other factors such as the parameter of mouse-movement track, the IO response time, to introduce uncertainty to its random number producer function. Through which we can get a better random number than normal pseudo random number. It's much more harder to predict.

那么,有没有一种方法可以在python中生成这样一个随机数,或者可以导入一个好的第三方库?

So, is there a way that in python we can produce such a random number, or maybe import a good third party library?

推荐答案

random模块的>文档这样说:

The documentation for the random module has this to say:

警告:不应出于安全目的使用此模块的伪随机数生成器.如果需要加密安全的伪随机数生成器,请使用os.urandom()或SystemRandom.

Warning: The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.

更多推荐

我可以使用python生成真实的随机数吗?

本文发布于:2023-11-30 21:11:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651485.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:随机数   可以使用   真实   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!