查看单词查找是否等于字典数据,然后打印字典定义

2024-10-04 11:31:40 发布

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

我有这个密码:

while True:
 words = {}
 aorl = raw_input("Add or look up a word (a/l)? ")
 if aorl == "a":
  word = raw_input("Type the word: ")
  definition = raw_input("Type the definition: ")
  words[word] = str(definition)
  print "Word added!"
 elif aorl == "l":
  type = raw_input("Type the word: ")
  if type == ??:
   ???

如果用户查找一个单词以找到定义,我将如何从字典中打印定义?你知道吗


Tags: theaddtrue密码inputrawif定义