teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

コード修正

2019/02/12 01:38

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -4,6 +4,6 @@
4
4
  [ignore spaces when comparing strings in python](https://stackoverflow.com/questions/16431964/ignore-spaces-when-comparing-strings-in-python)
5
5
  ```Python
6
6
  import difflib
7
- s = difflib.SequenceMatcher(lambda x: x in " \t", 'abc', 'abc ').ratio()
7
+ s = difflib.SequenceMatcher(lambda x: x in " \t", 'abc', 'a bc').ratio()
8
8
  print("match ratio:", s, "\n") # 一致(3+3) / 全体(3+4) = 6/7 = 0.8571428571428571
9
9
  ```