python实现猜拳游戏
Posted 子觉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python实现猜拳游戏相关的知识,希望对你有一定的参考价值。
import random; guess_list = [‘石头‘, ‘剪刀‘, ‘布‘]; rules = [[‘石头‘, ‘剪刀‘], [‘剪刀‘, ‘布‘], [‘布‘, ‘石头‘]]; computer = random.choice(guess_list); print(computer); people = input("石头, 剪刀, 布: ").strip(); isTrue = True; while isTrue: if people not in guess_list: people = input("石头, 剪刀, 布: ").strip(); else: isTrue = False; if people == computer: print(‘draw‘); elif [computer, people] in rules: print(‘computer is win‘); else: print(‘people is win‘);
以上是关于python实现猜拳游戏的主要内容,如果未能解决你的问题,请参考以下文章