思路:就是把石头剪刀布,1,2,3 你就把它当成数字相减,,................分出 等于0 等于-1 等于1....等等情况的输赢就好了
记得导包, import random
废话不多说,看代码:
import random
# print('''
# -----------------------------
# 请输入你的选择:
# 1. 石头
# 2. 剪刀
# 3. 布
# -----------------------------
# ''')
#方法1:
# while True:
# people = int(input("请选择出什么(只需要打出对应的数字):"))
# computer = random.randint(1, 3)
# if((people == 1 and computer == 2) or
# (people == 2 and computer == 3) or
# (people == 3 and computer == 1)):
# print("恭喜你获得了胜利!")
# elif people == computer:
# print("你好菜")
# else:
# print("平手")
#方法2:
# while True:
# computer = random.randint(1, 3)
# people = int(input("请选择出什么(只需要打出对应的数字):"))
# if computer - people == 0:
# print("平手")
# elif computer - people == 1 or computer - people == -2:
# print("恭喜你获得了胜利!")
# elif computer - people == 2 or computer - people == -1:
# print("再来一次吧")