可以使用與GNU補丁兼容的python模塊difflib創建補丁嗎? 我試圖用unified_diff和context_diff也試圖指定lineterm爲「\ n」,但我還是gettings此錯誤:Python difflib gnu補丁兼容性
[[email protected] Desktop]$ patch diff.patch test.txt
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
我用file.writelines(差異)來編寫補丁放到文件(件代碼http://pastebin.com/3HAWfwVf)
文件test.txt:
Hello, this is test
blah
文件的test2.txt:
Hello, this is test
blah, dfsgjdfgj
lfkdjgkldfjgkldfjgkl
而產生的補丁:
--- /home/intense/Desktop/test.txt
+++ /home/intense/Desktop/test2.txt
@@ -1,2 +1,7 @@
-Hello, this is test
-blah+Hello,+this+is+test+blah,+dfsgjdfgj+lfkdjgkldfjgkldfjgkl
感謝您的幫助。
我在哪裏可以找到它? –