我有這樣的代碼,效果很好。它的工作原理的方式,我必須鍵入功能,如足球的games.soccer模塊是活動的,那麼我可以輸入查詢,如「最新成績」,之後再次我關閉這個那麼對於這個工作類型autocare。我需要在編碼方式只需輸入查詢例如,「最新成績」 ..那麼這將遍歷所有進口功能,在播放字典找到answer.Here幫助是代碼我如何遍歷所有進口功能
import games
import clauseq11
PLAY = {
'soccer': games.soccer,
'nba': games.nba,
'autorace': games.autorace,
'search_name': clauseq11.search_name,
'answer_neg1': clauseq11.answer_neg1,
}
while True:
question = input('Please enter your question: ').lower()
if not question:
break
for key, func in PLAY.items():
if key in question:
func()
break
else:
print('Sorry I do not have an answer! :(')
請說明您的具體問題或添加額外的細節,突顯正是你需要的。正如目前所寫,很難確切地說出你在問什麼。參見[如何提出頁](http://stackoverflow.com/help/how-to-ask)尋求幫助澄清這一問題。 – jonrsharpe