Skip to content

Instantly share code, notes, and snippets.

@seozed
Created November 8, 2017 07:33
Show Gist options
  • Save seozed/7a8bac00d9316155345531f0c6c86561 to your computer and use it in GitHub Desktop.
Save seozed/7a8bac00d9316155345531f0c6c86561 to your computer and use it in GitHub Desktop.
比较字符串差异
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
"""
>>> similar("Apple","Appel")
0.8
>>> similar("Apple","Mango")
0.0
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment