【发布时间】:2014-05-21 23:21:33
【问题描述】:
我想知道如何从列表中获取随机颜色以在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))
这会导致我的代码崩溃,我还能尝试什么?
【问题讨论】:
-
你是随机导入的吗?随机导入
-
请更具体。它是如何崩溃的?显示什么错误?
标签: python list random tkinter