擅长:python、mysql、java
<p>正如DZinoviev上面所述,您将字符串传递到一个需要列表的函数中。您不需要使用NLTK,相反,您可以通过在句点上拆分来将字符串转换为句子列表。在</p>
<pre><code>import difflib
text1 ="""Physics is one of the oldest academic disciplines. Perhaps the oldest through its inclusion of astronomy. Over the last two millennia. Physics was a part of natural philosophy along with chemistry."""
text2 ="""Physics is one of the oldest academic disciplines. Physics was a part of natural philosophy along with chemistry. Quantum chemistry is a branch of chemistry."""
list1 = list(text1.split("."))
list2 = list(text2.split("."))
differ = difflib.Differ()
diff = differ.compare(list1,list2)
print "\n".join(diff)
</code></pre>