python - 有没有办法让 randint() 更少伪且更随机?
问题描述
我正在开发一个彩票模拟器,我对 randint 生成的抽奖并不满意。
有什么技巧可以让它更随机吗?
解决方案
No.
This is because randint()
is supposed to be pseudo-random - it, and the whole random
module, has that as its entire purpose.
If you want cryptographically-secure randomness, maybe look into the secrets
module instead:
The
secrets
module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.In particularly,
secrets
should be used in preference to the default pseudo-random number generator in therandom
module, which is designed for modelling and simulation, not security or cryptography.
推荐阅读
- c++ - 如何使这个 UDPSocket 对象成为全局对象,以便在其他功能中使用它?
- macos - 如何在 Mac OS 9 上设置 wxWidgets?
- c++ - 每次我尝试创建稀疏矩阵时的不同行为
- c# - 有没有办法在编辑器窗口中更快地绘制游戏对象?
- python - 为 plotly 指定数据单元中的标记大小
- python - 如何计算二维数组(Python)中一维数组的数量?
- r - ggplot 默认颜色的十六进制表示法
- java - Selenium 电网连接拒绝
- mysql - mysql 正确从多个表中拉取数据,没有重复和不正确的数据
- javascript - 根据另一个数组中的值获取键数组