python - How to create an auto increment seed in in python , making a heads or tails game?
问题描述
I've ended up with this code but I don't want to create a seed number on my own and want to by created by python:
import random
test_seed = int(input("Create a seed number"))
random.seed(test_seed)
random_side = random.randint(0, 1)
if random_side == 1:
print("Heads")
else:
print("Tails")
See if you can help me!
解决方案
您可以通过根本不提供种子来自动增加种子。
代替:
random.seed(test_seed)
利用:
random.seed()
这将根据系统时间为您提供种子,因此会自动增加(除非时间因某种原因停止)。
推荐阅读
- python - 通过替换 iterrows 来加速 pandas 代码
- sql - 当月轮转时如何按月分组
- javascript - 502 Bad Gateway nginx/1.14.1(Elastic Beanstalk 端口帮助)
- javascript - 如何在不刷新页面的情况下更新网站上的图片?
- r - 如何从 Docker 桌面 Windows 上的 Linux 容器中访问主机 ODBC 连接
- android - Liveload 不工作,webpack 上没有源文件夹
- java - Java 中静态数据库工厂方法的替代方案
- shell - 是否有参数可以更改通过 Shell 命令打印记事本的字体大小?
- mongodb - 在MongoDB中模拟返回结构的外部方法
- python - 如何使用 Chaquopy 和 openCV 打开 android 相机?