[英]How can I replace specific character from a string in python?
First, I tried to replace a couple of 'e' from the string and the string ended up like the following-首先,我尝试从字符串中替换几个“e”,字符串最终如下所示 -
string = 'Python is e high-level progremming lenguege'
How can I replace those 'e' with spelling errors leaving other 'e' unchanged?如何用拼写错误替换那些“e”,而其他“e”保持不变?
Try this solution here https://pypi.org/project/pyspellchecker/在此处尝试此解决方案https://pypi.org/project/pyspellchecker/
I hope i could help我希望我能帮上忙
you could use textblob.你可以使用文本块。
from textblob import TextBlob
text = "Python is e high-level progremming lenguege" # incorrect spelling
correct_text = TextBlob(text).correct()
print(correct_text)
>>> Python is e high-level programming language
Note: 'e' is not changed as 'a' because it corrects only spelling not letters or grammers.注意:“e”不会更改为“a”,因为它只纠正拼写而不是字母或语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.