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