I am a new-hand for python.
(我是python的新手。)
Got a annoying problem for a long time. (困扰了很长时间的问题。)
I am tring to make a look-up system.
(我正准备建立一个查找系统。)
But I hope it could be able to search words by keywords or whitelist.
(但我希望它能够通过关键字或白名单搜索单词。)
Here is my code:
(这是我的代码:)
help ={'A.Death':['dying','dead','mourir','pass away']}
my_dict = {'00.Life': help}
for name in my_dict.keys():
print(name)
test_pref = input('Please enter number:')
res = next(v for k, v in my_dict.items()
if k.startswith(test_pref.upper()))
if test_pref == '00':
for king in help.keys():
print(king)
inside_input = input('Please enter next number:')
res = next(v for k, v in help.items()
if k.startswith(inside_input.upper()))
print(res)
For now,I need to input 00 > input A to lookup the words, but could I skip the input, just input "die" to search ['dying','dead','mourir','pass away'] without "die" element in the list?
(现在,我需要输入00>输入A来查找单词,但是我可以跳过输入,只需输入“ die”来搜索['dying','dead','mourir','pass away']而不用“列表中的“死”元素?)
I hope :
(我希望 :)
Please enter keyword: die
> ['dying','dead','mourir','pass away']
Or should I make another list like ['die','dead'] to predict the searching word and associate with ['dying','dead','mourir','pass away']?
(还是我应该再列出一个列表,例如['die','dead']来预测搜索词并与['dying','dead','mourir','pass away']相关联?)
If yes, then how? (如果是,那怎么办?)
Please advise me.
(请给我提意见。)
ask by briiipo translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…