随机导入
导入时间
import os
os.system(“ color 02”)
Controls =(“ Controls:\ nR = Rock \ nP = Papper \ nS = Sicissors \ n”]
移动= ['r','p','s']
Player_Wins = ['rs','sp','pr']AI_Wins = ['sr','ps','rp']
P_Score = 0AI_Score = 0
print(“这是石头剪刀布游戏\ n”)
time.sleep(1)
print(“简单地说,您将面对我\ n \ n(计算机!)\ n”)
打印(控件)
同时为True:
P_Move = input("Your Move: ").lower
AI_Move = print("AI Move:",random.choice(Moves))
if P_Move + AI_Move in Player_Wins:
print("\nYou Win!\n")
P_Score = P_Score + 1
print(P_Score)
elif P_Move + AI_Move in AI_Wins:
print("\nAI Win!\n")
AI_Score = AI_Score + 1
print(AI_Score)
elif AI_Move == P_Move:
print("Tie")
P_Move
是一个函数,因为未调用.lower
方法。在其后添加()
,因此它将是一个字符串。
AI_Move
也不是str。它是None
,因为它是打印功能的结果,什么也不是。
正确的代码将是:
P_Move = input("Your Move: ").lower()
print("AI Move:")
AI_Move = random.choice(Moves)