石头剪刀布小游戏
一、代码
# 随机数示意
# Import random
# random.randint(1,3) 随机数在1到3选择
import random
def game1():
print("******************* 小可爱,游戏开始啦 *******************")
player_score = 0
inputs = {
"1": "石头", "2": "剪刀", "3": "布", "no": "退出"}
while True:
computer = str(random.randint(1, 3))
player = input("**小可爱请出拳 1-石头,2-剪刀,3-布,no-退出:") # 经过尝试,input为字符串模式时,输入小数/直接enter才不会报错。