Commit 50319d50 by BellCodeEditor

save project

parent 23dfff73
Showing with 27 additions and 0 deletions
import random,os,time
player_score=0
computer_score=0
while True:
os.system("cls")
computer_list=["石头","剪刀","布"]
player=input("请输入你想出的石头/剪刀/布:")
print("玩家出拳:"+ player)
if player not in computer_list:
print("输入操作有误,请重新输入")
continue
computer=random.choice(computer_list)
print("电脑出拳:",computer)
if player == computer:
print("平局")
elif (player=="布" and computer=="石头")or(player=="剪刀" and computer=="布")or(player=="石头" and computer=="剪刀"):
player_score=player_score+1
print("玩家赢了")
else:
computer_score=computer_score+1
print("玩家输了")
if player_score==2 or computer_score==2:
print(player_score,":",computer_score)
break
time.sleep(2)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment