grepfox 已修改 6 months ago. 還原成這個修訂版本
1 file changed, 1 insertion, 2 deletions
diff-check-txt.py
| @@ -13,5 +13,4 @@ for x in sorted(a - b): | |||
| 13 | 13 | ||
| 14 | 14 | print("\n---- Lines in misc1.txt but NOT in misc.txt ----") | |
| 15 | 15 | for x in sorted(b - a): | |
| 16 | - | print(x) | |
| 17 | - | hwc@arch ~/m | |
| 16 | + | print(x) | |
grepfox 已修改 6 months ago. 還原成這個修訂版本
1 file changed, 17 insertions
diff-check-txt.py(檔案已創建)
| @@ -0,0 +1,17 @@ | |||
| 1 | + | file1 = "misc.txt" | |
| 2 | + | file2 = "misc1.txt" | |
| 3 | + | ||
| 4 | + | with open(file1) as f: | |
| 5 | + | a = set(line.strip() for line in f) | |
| 6 | + | ||
| 7 | + | with open(file2) as f: | |
| 8 | + | b = set(line.strip() for line in f) | |
| 9 | + | ||
| 10 | + | print("---- Lines in misc.txt but NOT in misc1.txt ----") | |
| 11 | + | for x in sorted(a - b): | |
| 12 | + | print(x) | |
| 13 | + | ||
| 14 | + | print("\n---- Lines in misc1.txt but NOT in misc.txt ----") | |
| 15 | + | for x in sorted(b - a): | |
| 16 | + | print(x) | |
| 17 | + | hwc@arch ~/m | |