1
在我的python程序中,我正在讀取文件並將內容存儲在列表中。我檢查了列表中的每個索引,以便我知道它被正確存儲。 然後,我將一個特定的索引傳遞給包含藍色的類。 當它到達turtle.color
我得到一個錯誤壞顏色字符串:「藍色」在Python中使用龜的錯誤顏色字符串錯誤
例如: Team = Rainbow(str(sequence[0]),str(sequence[1]), str(sequence[2])) //index 2 (str(sequence[2])) contains "blue"
的我有一個類
class Rainbow:
def __init__(self, Rname, Rteam, Rcolor):
self.name = Rname
self.team = Rteam
self.color = Rcolor
self.Rturtle = turtle.Turtle()
self.Rturtle.color(self.color)//here is where I get the error
我確信一切都是進口正確地做了一些關於這個錯誤的研究,並且只是遇到了不好的序列問題。另外,如果我通過Team = Rainbow("Jay","Blue Jays","blue")
,我不會收到錯誤消息。
我在想,如果有人能幫助
我只是試過,它並沒有解決問題 – csciBeginner
碰巧有空白問題,但我不得不修覆文本文件,因爲.strip()沒有工作 – csciBeginner