#!/usr/bin/env python
# _*_ coding:utf-8 _*_

import difflib
text1 = """text1:       # 定义字符串1
This module provides classes and functions for comparing sequences.
including HTML and context and unified diffs.
difflib document v7.4
add string
"""
text1_lines = text1.splitlines()            # 以行进行分离,以便进行对比.
text2 = """text2:           # 定义字符串2
This module providess classes and functions for Comparing sequences.
including HTML and context and unified diffs.
difflib document v7.5"""
text2_lines = text2.splitlines()
d = difflib.Differ()        # 创建Differ()对象
diff = d.compare(text1_lines, text2_lines)  # 采用compare 方法对字符串进行比较
print '\n'.join(list(diff))

最新文章

  1. Python标准库--typing
  2. logback 配置详解(一)——logger、root
  3. mysql 索引查询的问题
  4. unity, reduce android size
  5. [java基础]分支结构(2)
  6. 2认识HTML中的“ML”:深入理解超文本
  7. Android 对Map按key和value分别排序
  8. Team Formation
  9. 分享第一次使用ProcessOn心得
  10. CSS3之响应式布局
  11. eclipse在多modules项目结构下避免模块间依赖引用的场景
  12. 邻里街坊 golang入坑系列
  13. php加密字符串超时不可解密
  14. 英式英语VS美式英语
  15. Windows Server 2016-安装AD域服务注意事项
  16. Edge BUG欣赏之四摸鸡与IP地址的恩怨
  17. JavaScript||什么是面向对象
  18. [android] 保存文件到手机内存
  19. 5.04-requests_cookies
  20. hdu-4180-exgcd

热门文章

  1. thinkphp控制器的使用
  2. java——arr == null || arr.length == 0
  3. wait、notify和notifyAll
  4. goodBye wordPress
  5. maya怎样卸载干净
  6. eclipse中使用自带的git提交项目
  7. PHP中的header()函数
  8. 【snmp】测试流程
  9. Fibonacci(斐波那契数列)的第N位数
  10. Sharepoint2010新建一个用户的方法