我想知道如何从列表中获取随机颜色以在draw_rectangle()
colors = ["red", "orange", "yellow", "green", "blue", "violet"]
canvas.create_rectangle(self.x, self.y, self.x + 60, self.y + 60, fill = random.choice(colors))
Run Code Online (Sandbox Code Playgroud)
这导致我的代码崩溃,我还能尝试什么?