Python中的 enchant.list_languages()
Enchant
是Python中的一个模块,用于检查单词的拼写,给出正确单词的建议。此外,给出单词的反义词和同义词。它检查字典中是否存在单词。
附魔.dict_exists()
附魔enchant.list_languages()
是enchant
模块的内置方法。它用于列出字典可用的语言。
Syntax : enchant.list_languages()
Parameter : Nothing
Returns : a list of language codes for which dictionaries are available
# import the enchant module
import enchant
# list the languages for which
# dictionaries are available
print(enchant.list_languages())
输出 :
[‘en_BW’, ‘en_AU’, ‘en_BZ’, ‘en_GB’, ‘en_JM’, ‘en_DK’, ‘en_HK’, ‘en_GH’, ‘en_US’, ‘en_ZA’, ‘en_ZW’, ‘en_SG’, ‘en_NZ’, ‘en_BS’, ‘en_AG’, ‘en_PH’, ‘en_IE’, ‘en_NA’, ‘en_TT’, ‘en_IN’, ‘en_NG’, ‘en_CA’]
示例 2:使用enchant.dict_exists()
验证enchant.list_languages()
生成的所有语言代码是否存在于enchant
中。
# import the enchant module
import enchant
for lang in enchant.list_languages():
if enchant.dict_exists(lang):
print("The dictionary for " + lang + " exists.")
else:
print("The dictionary for " + lang + " does not exists.")
输出 :
The dictionary for en_BW exists.
The dictionary for en_AU exists.
The dictionary for en_BZ exists.
The dictionary for en_GB exists.
The dictionary for en_JM exists.
The dictionary for en_DK exists.
The dictionary for en_HK exists.
The dictionary for en_GH exists.
The dictionary for en_US exists.
The dictionary for en_ZA exists.
The dictionary for en_ZW exists.
The dictionary for en_SG exists.
The dictionary for en_NZ exists.
The dictionary for en_BS exists.
The dictionary for en_AG exists.
The dictionary for en_PH exists.
The dictionary for en_IE exists.
The dictionary for en_NA exists.
The dictionary for en_TT exists.
The dictionary for en_IN exists.
The dictionary for en_NG exists.
The dictionary for en_CA exists.
在评论中写代码?请使用 ide.geeksforgeeks.org,生成链接并在此处分享链接。