在 Python 中,你可以使用模块 pyenchant
来查找 word 中的错别字。
首先,你需要安装 pyenchant
模块:
pipinstall pyenchant
然后,你可以使用下面的代码来查找 word 中的错别字:
import enchant# 读取 word 文件
with open("word.txt", "r") as f:
text = f.read()
# 创建拼写检查器
spell_checker = enchant.Dict("en_US")
# 查找错别字
mispelled_words = []
<