python石头剪刀布游戏
In this article, I will be showing you step by step how to make a full python rock-paper-scissor game easily. I won’t be using any hard ways so even beginners can understand how it works.
在本文中,我将逐步向您展示如何轻松制作完整的python石头剪刀布游戏。 我不会使用任何困难的方法,因此即使是初学者也可以理解它的工作原理。
下面是程序的外观: (Here’s how the program will look at end:)
To check out the full code in advance:
要提前查看完整代码,请执行以下操作:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/45c9ed6638b1da5c44d41e6f3b0278ef.png)
让我们开始吧! (Lets get Started!)
So let’s import all the things that we will need. And that will be:
因此,让我们导入我们需要的所有东西。 那将是:
步骤1:导入所有必要的文件 (Step 1: Import all necessary files)
- Randint from random module 来自随机模块的Randint
- Sleep from time module 从时间模块Hibernate
![Image for post](https://miro.medium.com/max/9999/1*j9hpurqLERLwNk7IdnBJag.png)
You will know later what each of this will be used for later on.
稍后您将知道这些功能将用于以后的工作。
步骤2:建立游戏变数 (Step 2: Create game variables)
So first, we must give the player a choice of what to choose from Paper, Rock or Scissor.
因此,首先,我们必须让玩家选择“纸”,“石头”或“剪刀”。
For that let’s make a list called choices to store that for easier access to game variables.