Python error: cannot concatenate 'str' and 'builtin_function_or_method' objects

Python error: cannot concatenate 'str' and 'builtin_function_or_method' objects

我目前正在 Python 编写基于文本的冒险作为学习练习。到目前为止,玩家可以命名自己,其值存储在字典键中。但是,当我试图让玩家选择他们的种族时,出现以下错误:

无法连接 'str' 和 'builtin_function_or_method' 个对象

我一遍又一遍地检查我的代码,但似乎无法弄清楚哪里出了问题。我对 Python 有点陌生,所以我认为我忽略了一些简单的事情。

player = {
    "name": "",
    "gender": "",
    "race": "",
    "class": "",
    "HP": 10,
}

def error():
    print "Error: Unknown Command"

print "You will have to forgive me, " + player['name'] + ". My eyesight isn't what it used to be. What are you, exactly?."
print "- A mighty HUMAN"
print "- A hardy DWARF"
print "- An ingenious GNOME "
print "- or an elegant ELF"
print "(Hint: If you would like to know more about each race, consult the manual, whatever that means)"
player_race = raw_input(">> ").lower
while race_confirm == False:
    if player_race != "elf":
        print "You say you're a " + player_race + ". Is that correct? Remember, you will be unable to change your race later. (Y/N)" 
        response = raw_input(">> ").lower()
    else:
        print "You say you're an " + player_race + ". Is that correct? Remember, you will be unable to change your race later. (Y/N)" 
        response = raw_input(">> ").lower()
    if response == "y":
        player_race = player['race']
        print "It is nice to meet you, ", player['name'] + "the" + player['race'] + "."
        race_confirm = True
    elif response == "n":
        print "Oh, I'm terribly sorry. I must have misheard you. What did you say you were again?"
        player_name = raw_input(">> ")
    else:
        error()

您需要调用那个较低的方法,它是一个 可调用 属性:

player_race = raw_input(">> ").lower()
#                                   ^^