Comparing two text files in python

前端 未结 4 1236
执念已碎
执念已碎 2021-02-05 12:20

I need to compare two files and redirect the different lines to third file. I know using diff command i can get the difference . But, is there any way of doing it in python ? An

4条回答
  •  悲哀的现实
    2021-02-05 13:13

    check out difflib

    This module provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce difference information in various formats, including HTML and context and unified diffs[...]

    A command-line example in http://docs.python.org/library/difflib.html#difflib-interface

提交回复
热议问题