Python中使用Tu的错误颜色字符串错误

2024-04-26 21:15:46 发布

您现在位置:Python中文网/ 问答频道 /正文

在python程序中,我从一个文件中读取并将内容存储在一个列表中。我检查了列表的每个索引,所以我知道它存储正确。 然后我将一个特定的索引传递给一个包含蓝色的类。 每当它到达turtle.color时,我就会得到一个错误错误的颜色字符串:“blue”

例如: 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"),我不会得到错误。在

我想知道是否有人能帮忙


Tags: self程序列表错误blueteamcolorsequence