更新时间:2022-04-03 05:49:33
您只需要进行替换,包括**mispelledword**
部分.
You just need to do the replacement including the **misspelledword**
part.
import enchant
from enchant.checker import SpellChecker
chkr = SpellChecker("en_UK","en_US")
spacedfile = "This is a setence. It has speeelinng mistake."
chkr.set_text(spacedfile)
for err in chkr:
sug = err.suggest()[0]
err.replace("**%s** %s" % (err.word, sug)) # Look here
Spellchecked = chkr.get_text()
print Spellchecked