- #coding:utf-8
- """
- 迪艾姆python培训 黄哥所写
- """
- import random
- guess_list = ["石头","剪刀","布"]
- guize = [["布","石头"],["石头","剪刀"],["剪刀","布"]]
- while True:
- computer = random.choice(guess_list)
- people = input('请输入:石头,剪刀,布\\n').strip()
- if people not in guess_list:
- people = input('重新请输入:石头,剪刀,布\\n').strip()
- continue
- if computer == people:
- print("平手,再玩一次!")
- elif [computer,people] in guize :
- print("电脑获胜!")
- else:
- print("人获胜!")
- break
- #该片段来自于http://www.codesnippet.cn/detail/280220148837.html
来源: http://www.codesnippet.cn/detail/280220148837.html