Python:在difflib中传递SequenceMatcher;自动垃圾=False";标志产生错误
我将使用Python的difflib包中的SequenceMatcher方法来识别字符串相似性。不过,我在使用该方法时遇到了奇怪的行为,我相信我的问题可能与包的“垃圾”过滤器有关,这是一个详细描述的问题。我只想说,我认为我可以通过以下方式将autojunk标志传递给SequenceMatcher来解决我的问题: 但这会产生以下错误消息:Python:在difflib中传递SequenceMatcher;自动垃圾=False";标志产生错误,python,design-patterns,flags,difflib,sequencematcher,Python,Design Patterns,Flags,Difflib,Sequencematcher,我将使用Python的difflib包中的SequenceMatcher方法来识别字符串相似性。不过,我在使用该方法时遇到了奇怪的行为,我相信我的问题可能与包的“垃圾”过滤器有关,这是一个详细描述的问题。我只想说,我认为我可以通过以下方式将autojunk标志传递给SequenceMatcher来解决我的问题: 但这会产生以下错误消息: Traceback (most recent call last): File "test3.py", line 8, in <module>
Traceback (most recent call last):
File "test3.py", line 8, in <module>
print matches("they all are white a sheet of spotless paper when they first are born but they are to be scrawled upon and blotted by every goose quill", "you are all white a sheet of lovely spotless paper when you first are born but you are to be scrawled and blotted by every gooses quill")
File "test3.py", line 4, in matches
s = difflib.SequenceMatcher(None, s1, s2, autojunk=False)
TypeError: __init__() got an unexpected keyword argument 'autojunk'
回溯(最近一次呼叫最后一次):
文件“test3.py”,第8行,在
打印火柴(“刚出生的时候,它们都是白色的,一张一尘不染的纸,但每根鹅毛笔都会在上面乱涂乱画”,“刚出生的时候,你们都是白色的,一张可爱的、一尘不染的纸,但每根鹅毛笔都会乱涂乱画。”
文件“test3.py”,第4行,匹配项
s=difflib.SequenceMatcher(无、s1、s2、自动垃圾=False)
TypeError:\uuuu init\uuuuuuuuuuuuu()获取了意外的关键字参数“autojunk”
有人知道我如何将autojunk=False标志传递给SequenceMatcher吗?如果其他人能提供任何建议,我将不胜感激。根据:
可选参数autojunk可用于禁用自动垃圾启发
版本2.7.1中新增:自动垃圾参数
升级到Python 2.7.1+以使用
autojunk
参数。您使用哪一版本的Python?最好升级到2.7.6-真的没有理由“升级”到过期多年的版本;-)
Traceback (most recent call last):
File "test3.py", line 8, in <module>
print matches("they all are white a sheet of spotless paper when they first are born but they are to be scrawled upon and blotted by every goose quill", "you are all white a sheet of lovely spotless paper when you first are born but you are to be scrawled and blotted by every gooses quill")
File "test3.py", line 4, in matches
s = difflib.SequenceMatcher(None, s1, s2, autojunk=False)
TypeError: __init__() got an unexpected keyword argument 'autojunk'