python3里面比较两个字符串的不同【difflib】

一、difflib库的用法
        a = '/Users/melon/Desktop/odoo14/myaddons/watermark_design/fonts/SimSun.ttf'
        b = '/Users/melon/Desktop/odoo14/myaddons/watermark_design/models/fonts/SimSun.ttf'
        from difflib import Differ
        d = Differ()
        diff = d.compare(a.splitlines(), b.splitlines())
        print('\n'.join(list(diff)))

 

 

 

posted @ 2022-03-08 22:39  何双新  阅读(331)  评论(0编辑  收藏  举报