Python Print Max Line Fuzzy Ratio From A File
I am trying a python code,to find the maximum fuzzy ratio of all the line in the text file with the word 'good',the line having the max fuzzy ratio will be printed.I tried a progra
Solution 1:
A short solution will probably be of this form:
defgood_ratio(a):
return fuzz.ratio(a, 'good')
withopen('qwer.txt', 'r') as my_file:
print(max(my_file, key=good_ratio))
or even shorter
withopen('qwer.txt', 'r') as my_file:
print(max(my_file, key=lambda a: fuzz.ratio(a, 'good')))
Post a Comment for "Python Print Max Line Fuzzy Ratio From A File"