2016-07-20 44 views
0

我目前正在編程一個基於文本的冒險,在Python中作爲學習練習。到目前爲止,玩家可以自己命名,其價值存儲在字典鍵中。然而,當我試圖讓玩家選擇自己的種族,我得到以下錯誤:Python錯誤:無法連接'str'和'builtin_function_or_method'對象

不能連接「海峽」和「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() 

回答

0

你需要調用較低的方法,這是一個調用屬性:

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

我很生氣我自己,我真想大叫一聲。有時你需要的只是第二組眼睛。非常感謝! –

相關問題