def find_acronym():
# if search term in database returns acronym and expansion
for abbr, text in acronyms.items():
if abbr == search_analyte.get():
expansion.insert(0.0,'{0:>6}: {1: <10}\n'.format(abbr, text))
elif str(search_analyte.get()) in text:
expansion.insert(0.0,'{0:>6}: {1: <10}\n'.format(abbr, text))
# if search term not in database , returns message DOES NOT WORK PROPERLY!
if search_analyte.get() not in text or abbr != search_analyte.get():
expansion.insert(0.0,'"{0}"{1} \n {2}\n'.format(search_analyte.get(),' is not in the database.','Add,if appropriate'))
この関数を使用して、頭字語の辞書とそれに関連する拡張された意味を次の形式で検索します{ ACRONYM: text details, ACRONYM2: its test,...}
このアルゴリズムは、任意の検索項目の頭字語とテキストを取得するという意味で機能しますが、項目がデータベースにあるかどうかを検出することを意図した最後の if 条件からのテキスト メッセージも常に返します。私は明らかに非論理的であるか、Python でループがどのように機能するかを理解していません。