我有两个字符串,a
和b
,我可以使用a.index(b)
在字符串a
中查找字符串b
的索引.
a = """
Hello! This is a string which I am using to present a quesion to stackoverflow because I ran into a problem.
How do I solve this?
If anyone knows how to do this, please help!
"""
b = "How do I solve this"
idx = a.index(b)
但当字符串b
不完全是字符串a
的一部分时,这就行不通了.例如,字符串b
为:
b = "How fo I solve rhis"
我想要一种方法,当"不匹配"字符数最多为5时,我们可以在a
中找到b
的索引.