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