用户:2nd一FCX寂寞的bat查看:0 回复:2 评论:0 创建时间:2020-04-11T10:34:42
import random
print('猜拳游戏')
a = []
a.append('石头')
a.append('剪刀')
a.append('布')
intrue = 1
while intrue:
c = random.randint(0, 2)
e = input('请猜一个手势或退出:')
if (a[c] == '石头' and e == '剪刀'):
print(a[c])
print('你输了')
if (a[c] == '石头' and e == '布'):
print(a[c])
print('你输了')
if (a[c] == '剪刀' and e == '石头'):
print(a[c])
print('你赢了')
if (a[c] == '剪刀' and e == '布'):
print(a[c])
print('你输了')
if (a[c] == '布' and e == '石头'):
print(a[c])
print('你输了')
if (a[c] == '布' and e == '剪刀'):
print(a[c])
print('你赢了')
if (a[c] == '剪刀' and e == '剪刀'):
print(a[c])
print('平')
if (a[c] == '石头' and e == '石头'):
print(a[c])
print('平')
if (a[c] == '布' and e == '布'):
print(a[c])
print('平')
if (e == '退出'):
intrue = 0
变量c是系统,变量e是玩家。
因为我接触python只有半年,所以if有点多。