|
吾爱游客
发表于 2023-9-8 11:31
1、申 请 I D :kill999
2、个人邮箱:1214609339@qq.com
3、原创技术文章:用python写了一个简单的猜拳游戏,以下是源码
import random
import datetime
import os
xlm = 0 #初始化xlm
while xlm <= 3 : #xlm>3便不在循环
person = int(input("石头(1),剪刀(2),布(3)")) #输入123即可选择石头剪刀布
computer = random.randint(1,3) #电脑随机数范围未1-3
if person == 1: #判断并打印出石头剪刀布
print ("养鱼人:石头")
elif person == 2:
print("养鱼人:剪刀")
elif person == 3:
print("养鱼人:布")
elif person >3:
print("超出范围了")
if computer == 1:
print("电脑:石头")
elif computer == 2:
print("电脑:剪刀")
else:
print("电脑:布")
if person == computer: #判断输赢的条件
print ("平分秋色")
elif person == 1 and computer == 2 or person == 2 and computer == 3 or person == 3 and computer == 1:
print("恭喜你!你赢了")
#break
elif person == 1 and computer == 3 or person == 2 and computer == 1 or person ==3 and computer == 2:
print("很遗憾!你输了")
#xlm +=1
else:
print("你想飞啊")
xlm +=1
time1 = datetime.datetime.now() #获取现在的时间
print (time1) #打印时间
|
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|