Enchant是python中的一个模块,用于检查单词的拼写,并提供纠正单词的建议。另外,给出单词的反义词和同义词。它检查字典中是否存在单词。
enchant .dict_exists()
enchant.list_languages()
是一种内置方法enchant
模块。它用于列出可用字典的语言。
用法: enchant.list_languages()
参数:没有
返回:可用字典的语言代码列表
# 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.list_languages()
存在于enchant
还是不使用enchant.dict_exists()
。
# 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.
相关用法
注:本文由纯净天空筛选整理自Yash_R大神的英文原创作品 enchant.list_languages() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。