我正在尝试迭代"截止" difflib.get_close_matches的参数使用以下代码:
import difflib
from numpy import loadtxt
text_file = open('filewithtext.txt', "r")
lines = text_file.read().split(',')
word = 'word_to_search_in_file'
for i in range(0,0.4):
difflib.get_close_matches(word, lines, n=10, cutoff=i)
我收到以下错误:
TypeError Traceback (most recent call last)
<ipython-input-224-a5dc535e6b28> in <module>()
2 word = 'word_to_search_in_file'
3
----> 4 for i in range(0,0.4):
5 difflib.get_close_matches(word, lines, n=10, cutoff=i)
TypeError: 'float' object cannot be interpreted as an integer
我的问题是 - 如何迭代cutoff参数,让函数运行为分配给截止值的数字列表
感谢。