python小游戏(剪刀石头布)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python小游戏(剪刀石头布)相关的知识,希望对你有一定的参考价值。

#!/usr/bin/python
#-- coding: utf8--
import random #导入随机数的模块

computer = random.choice([‘石头‘, ‘剪刀‘, ‘布‘])
player = raw_input(‘请出拳(石头/剪刀/布): ‘)

print "Your choice: %s, Computer‘s choice: %s" % (player, computer)
if player == ‘石头‘:
if computer == ‘石头‘:
print ‘平局‘
elif computer == ‘剪刀‘:
print ‘You WIN!!!‘
else:
print ‘You LOSE!!!‘
elif player == ‘剪刀‘:
if computer == ‘石头‘:
print ‘You LOSE!!!‘
elif computer == ‘剪刀‘:
print ‘平局‘
else:
print ‘You WIN!!!‘
else:
if computer == ‘石头‘:
print ‘You WIN!!!‘
elif computer == ‘剪刀‘:
print ‘You LOSE!!!‘
else:
print ‘平局‘

以上是关于python小游戏(剪刀石头布)的主要内容,如果未能解决你的问题,请参考以下文章

零基础学python第六课, 开发剪刀石头布小游戏

零基础学python第六课, 开发剪刀石头布小游戏

Python Tkinter实战案例,搞定剪刀石头布小游戏,就是这么强!

python 石头剪刀布游戏

python实现猜拳游戏

python-编写石头剪刀布小游戏