我從一些基本的東西開始,以獲得如何製作基於文本的遊戲的感覺。在IDE中創建.py文件後,打開終端並使用bash打開.py文件。不能連接「str」和「
hpGanon = 10
damage = input("How much damage did you do with the Master Sword?")
hpGanon = hpGanon - damage
print("Ganon now has " + hpGanon + "hit points.")
在時,我想它打印結束時,bash告訴我,它不能連接「海峽」和「廉政」的對象。 我試過下面哪些是在下面的文章中說,Python: TypeError: cannot concatenate 'str' and 'int' objects 但我我沒有得到我想要的結果
我只是想說:「Ganon現在有x點生命值。」 任何想法?
嘗試' 「加農現擁有」 + STR(hpGanon)+ 「打點。」' –
你似乎是在Python 2上,不是Python 3. – user2357112
爲什麼你認爲'bash'給你這個錯誤?它應該來自Python。 Bash與運行Python腳本時發生的情況無關。 – Barmar