0
我一直堅持這個我一直在試驗的基本程序。獲取錯誤:並非所有在字符串格式化過程中轉換的參數
這裏是我的代碼:
def description1(self):
desc = "%s is a %s, attack %s , health %s , defence %s , speed $s"%(self.name, self.description, self.attack, self.healthPoints, self.defence, self.speed)
return desc
以下是錯誤消息:
line 9, in description1
desc = "%s is a %s, attack %s , heath %s , defence %s , speed $s"%(self.name, self.description, self.attack, self.healthPoints, self.defence, self.speed)
TypeError: not all arguments converted during string formatting
我使用Python 3.5。
你'速度$ s',推測你的意思'%s'。由於錯字你只有5'%s',但元組中有6項 - 因此是錯誤。 – AChampion
此外,縮進全部關閉 – AetherUnbound