Python误解了我的lis

2024-04-25 19:36:03 发布

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

出于某种原因,Python不断抛出一个TCL错误,其中表示“Unknown color”,尽管它从中获取字符串的列表与颜色无关。有什么原因吗?你知道吗

#Add words to this list to include them in the game
words = ["Games","Development","Keyboard","Speed","Typer","Anything","Aplha","Zealous","Accurate","Basics","Shortcut","Purpose","Window","Counter","Fortress","Modification","Computer","Science","History","Football","Basketball","Solid","Phantom","Battlefield","Avdvanced","Warfare","Download","Upload","Antidisestablishmentarianism","Supercalifragilisticexpialidocious","Discomobobulation","Liberated","Assassin","Brotherhood","Revelation","Unity","Syndicate","Victory"]

def nextWord():
        global score
        entry.focus_set()
        if entry.get().lower() == words[1].lower():
            score += 1

        entry.delete(0, tkinter.END)
        random.shuffle(words)
        label.config(fg=str(words[1]), text=str(words[0]))
        scoreLabel.config(text="Score: " + str(score))

这是新的错误:

ValueError: dictionary update sequence element #0 has length 1; 2 is required

另外,我知道我的一些/大部分代码可能不正确,我想知道如何设置一个最大的时间来洗牌和显示一个字符串,然后再打印他们所花的时间,通过所有的标签前进。(第二个问题,不想回答就不用回答) 谢谢。你知道吗


Tags: to字符串textconfig列表错误时间tcl
1条回答
网友
1楼 · 发布于 2024-04-25 19:36:03

你明确地告诉tkinter使用这个词作为颜色;这就是fg行中label.config(fg=str(words[1]),...)所做的。你知道吗

既然不是颜色,你就不应该那样做。你知道吗

相关问题 更多 >