TypeError:+不支持的操作数类型:'builtin_function_or_method'和'NoneType'

问题描述 投票:0回答:1

随机导入

导入时间

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")
python-3.7
1个回答
0
投票

P_Move是一个函数,因为未调用.lower方法。在其后添加(),因此它将是一个字符串。

AI_Move也不是str。它是None,因为它是打印功能的结果,什么也不是。

正确的代码将是:

P_Move = input("Your Move: ").lower()
print("AI Move:")
AI_Move = random.choice(Moves)
© www.soinside.com 2019 - 2024. All rights reserved.