Skip to content

Commit d042a87

Browse files
committed
filecmp&difflib模块
filecmp&difflib模块
1 parent 42efa41 commit d042a87

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#新建两个文件f1 和 f2
2+
#f1存储的数据是1,2,3
3+
#f2存储的数据是4,5,6
4+
import filecmp
5+
print(filecmp.cmp("f1","f1"))
6+
print(filecmp.cmp("f1","f2"))
7+
8+
9+
import difflib
10+
from pprint import pprint
11+
12+
a = 'pythonclub.org is wonderful'
13+
b = 'Pythonclub.org also wonderful'
14+
s = difflib.SequenceMatcher(None, a, b)
15+
16+
print ("s.get_matching_blocks():")
17+
pprint(s.get_matching_blocks())
18+
print ("s.get_opcodes():")
19+
for tag, i1, i2, j1, j2 in s.get_opcodes():
20+
print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))
21+

day043-statistics/statistics.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)