[python]代码库
import random
user_score = 0
sys_score = 0
while True:
choose = int(input('请出拳 (1-剪刀; 2-石头; 3-布): '))
list_choose = ['剪刀', '石头', '布']
# 用户出拳
print('玩家出拳: %s\t' % list_choose[choose-1], end='')
# 系统出拳
sys_choose = random.randint(1,3)
print('系统出拳: %s' % list_choose[sys_choose-1])
# 判断结果
if ((choose == 1 and sys_choose == 2) or
(choose == 2 and sys_choose == 3) or
(choose == 3 and sys_choose == 1)): # 用户赢
user_score += 1
print('恭喜你,赢了!')
elif choose == sys_choose: # 平局
print('平局!')
else: # 用户输
sys_score += 1
print('抱歉,输了!')
# 局部结束
user_choice = input('是否继续(y/n)? ')
if user_choice == 'n':
break
# Game Over
print('游戏结束!\n你的得分:%d\t系统得分:%d' % (user_score, sys_score))