python石头剪刀布游戏代码
时间: 2023-10-09 14:08:11 浏览: 216
python 石头剪刀布游戏
游戏介绍:
数字1代表石头
数字2代表剪刀
数字3代表布
游戏次数:
```python
import random
def game():
count = 0
while count < 5:
count += 1
guess = int(input("请输入你的选择(1-石头,2-剪刀,3-布):"))
computer = random.randint(1, 3)
if guess == computer:
print("平局!")
elif (guess == 1 and computer == 2) or (guess == 2 and computer == 3) or (guess == 3 and computer == 1):
print("你赢了!")
else:
print("你输了!")
game()
```
阅读全文