小工具中用的部分测试文件见附件
对比文本文件中不同的行
最近有两个项目苹果帐号中新增了内测帐号,新老包里面包含的内测设备不同,想要查看新包(内测设备多)中比老包多了哪些。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| # # -*- coding: utf-8 -*-
oldname = open('./old.txt', 'r') newname = open('./new.txt', 'r')
oldnameLines = oldname.readlines() newnameLines = newname.readlines()
diffentLine = []
def compare(lineArr = newnameLines, diff = []): if len(lineArr) == 0: return diff
newLine = lineArr.pop().strip('\n') # 去除首尾的换行符 isEqual = False for oldIndex, oldLine in enumerate(oldnameLines): isEqual = isEqual or (oldLine.strip('\n') == newLine) if not isEqual: diffentLine.append(newLine) return compare(lineArr, diffentLine)
print(compare()) oldname.close() newname.close()
|
附件
new.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| 4f851ad814c6d77a5ea338252f34e16df81fbc00 475357e205787e8d10137e6b94235dc4639a50ca 6ec05b7b2bbcb2e16c07371f7119181318ed5e31 06a82bb82c968ad33f2e1f9a08ea0cf226c91b68 92027bb11f343ebee913d4ba2839772d6db8bb35 1b47c9464abcdaacefcf2578a0c45f2ab8a21b43 f5c7fbbeda40b760ca2fde524cd81ffbd0c9422a 0ffcba04614d17f7a00847d20494bd7ecf6caf68 0d9853735ecbe268fa34f056cba3a5a5c75dd965 4ba944040c39e795d167107e7a645aee2b65975f c6acded6038a3fb6ca5076d855b25da9592fcab4 783cf4b827e404b53d2c103f429dd069e22af84e 505a08876413b1bfc8778816d97252efdc91cc36 e56aaf51ab3fadd7ea590f9155a2e184aecdfbc4 fc5035ff9054f06d1f6282a260289a75b3949e63 62120d790c969cecf154da5948695cd69904d092 91650d655e74e4a0b815d096d0ef79c392192c77 807a51fa7e3aaa0e16df566db051059d96697426 1da74bb82b56096e321bccd2fab2b6bff48d6c86 90e4b1307cc4fb6e34e62c3294fbb7839c2a70ef 4ab76842b7ba039710798d6a9eb830c55df73cbb dcaa1d5b1c8fd27442574ae837393755da71d16d 0c7924df887951c5cac3b21a89e3695a7fef2a6e 6362435cd09c0d2391b1fc08f0952d6bc6d7dbcc af1bf307fb70fa070364e1f54ab9f6b8d887d6dd 1fcf4fef19fec7a93e26bca99605471d7915f3a2 6713bfb31dab974d2687066d07cf1d712ecb31a6 551c9117f0764536731fbbc88bd4f7a0da175679 25ed04606015c995d3a7750b9d21d12822bd0af6 678dd79aeb82895c22aa8a47e027c85f994a6ddd d92dc6ea51455310f32ef64f4e5fd9196f240ede a56ed28080da0f1725b7544bbae5f3591e740983 85e0f9227c8371ef99b1a56a7d495b3cc6b236a9 762ca3d4d8084c19154638a602e85c38a749f0b4 63f439a8bd30a5a2260e2ddf8f86e28bdd16b36b 3843efb916d23918232db89cb9b94938b5b7236a 6822472aff3e7886e0bd1a2bd86d194f48cd5052 65e83901bda2bdd957b4e21e1decfc5b177a98b3 74c1dd4113ac402fdfd38db7e1818be24735df4b 3364f575ca6f4054e91f7273bbf1dfcd057a4786 d903633e56ae8d6b94c16e692eba444c7c7d1921 56aa342af4f8aa7b754e99f6b7055631e7b22777 c89dd5acb93348ca0f1aa21d5cf6913991c18efc dcf95ad21448ba577e18fddef6054c1b710d542f 0b17cda0b6a008b8788796964d1e31f7575af6cd 3b96a534dea4f3ca38e00af4e745b99dd8531d1b 13845da2e45fb544a50e6b704fa52072e26c9f1e fa9d2238b1ebb1470db2fb481828a349b5a2a9e5 45678fc84e20d4c87e90ccde39a11f535f184e3c 274c9cb3e8e987dbfdc124a741c43bec26e7f613 c1123101960355d369565f304516f4a39ef73ce3 e40df6a49aaa08050feaae6378a1726aee29c5f6 74903746a8ad1192aa29b770b551c281d490dd1e f81d05093e600d7e676eab4c593624f717d76148 e5d39be4a4a9322ce62535afa3149d3b5df35360 02ceeca08a961c4877929c4d852ea53dbe37a930 36a59b8f7cd8d0d97f2cfb538a3ac02f6de908b4 b9ee3ffabd0c7e2383b54d61df8e00613b0696f1 6f1cab6c58c72583f01532f49b1957242ecea4f3 c970415d8113bffc50c10c339c7c2baf1e491a35
|
old.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| 4f851ad814c6d77a5ea338252f34e16df81fbc00 475357e205787e8d10137e6b94235dc4639a50ca 6ec05b7b2bbcb2e16c07371f7119181318ed5e31 06a82bb82c968ad33f2e1f9a08ea0cf226c91b68 92027bb11f343ebee913d4ba2839772d6db8bb35 1b47c9464abcdaacefcf2578a0c45f2ab8a21b43 f5c7fbbeda40b760ca2fde524cd81ffbd0c9422a 0ffcba04614d17f7a00847d20494bd7ecf6caf68 0d9853735ecbe268fa34f056cba3a5a5c75dd965 4ba944040c39e795d167107e7a645aee2b65975f c6acded6038a3fb6ca5076d855b25da9592fcab4 783cf4b827e404b53d2c103f429dd069e22af84e 505a08876413b1bfc8778816d97252efdc91cc36 e56aaf51ab3fadd7ea590f9155a2e184aecdfbc4 fc5035ff9054f06d1f6282a260289a75b3949e63 62120d790c969cecf154da5948695cd69904d092 91650d655e74e4a0b815d096d0ef79c392192c77 807a51fa7e3aaa0e16df566db051059d96697426 1da74bb82b56096e321bccd2fab2b6bff48d6c86 90e4b1307cc4fb6e34e62c3294fbb7839c2a70ef 4ab76842b7ba039710798d6a9eb830c55df73cbb dcaa1d5b1c8fd27442574ae837393755da71d16d 0c7924df887951c5cac3b21a89e3695a7fef2a6e 6362435cd09c0d2391b1fc08f0952d6bc6d7dbcc af1bf307fb70fa070364e1f54ab9f6b8d887d6dd 1fcf4fef19fec7a93e26bca99605471d7915f3a2 6713bfb31dab974d2687066d07cf1d712ecb31a6 551c9117f0764536731fbbc88bd4f7a0da175679 25ed04606015c995d3a7750b9d21d12822bd0af6 678dd79aeb82895c22aa8a47e027c85f994a6ddd d92dc6ea51455310f32ef64f4e5fd9196f240ede a56ed28080da0f1725b7544bbae5f3591e740983 85e0f9227c8371ef99b1a56a7d495b3cc6b236a9 762ca3d4d8084c19154638a602e85c38a749f0b4 63f439a8bd30a5a2260e2ddf8f86e28bdd16b36b 3843efb916d23918232db89cb9b94938b5b7236a 6822472aff3e7886e0bd1a2bd86d194f48cd5052 65e83901bda2bdd957b4e21e1decfc5b177a98b3 74c1dd4113ac402fdfd38db7e1818be24735df4b 3364f575ca6f4054e91f7273bbf1dfcd057a4786 d903633e56ae8d6b94c16e692eba444c7c7d1921 56aa342af4f8aa7b754e99f6b7055631e7b22777 c89dd5acb93348ca0f1aa21d5cf6913991c18efc 0b17cda0b6a008b8788796964d1e31f7575af6cd 3b96a534dea4f3ca38e00af4e745b99dd8531d1b 13845da2e45fb544a50e6b704fa52072e26c9f1e fa9d2238b1ebb1470db2fb481828a349b5a2a9e5 45678fc84e20d4c87e90ccde39a11f535f184e3c 274c9cb3e8e987dbfdc124a741c43bec26e7f613 c1123101960355d369565f304516f4a39ef73ce3 e40df6a49aaa08050feaae6378a1726aee29c5f6 74903746a8ad1192aa29b770b551c281d490dd1e f81d05093e600d7e676eab4c593624f717d76148 e5d39be4a4a9322ce62535afa3149d3b5df35360 02ceeca08a961c4877929c4d852ea53dbe37a930 36a59b8f7cd8d0d97f2cfb538a3ac02f6de908b4 b9ee3ffabd0c7e2383b54d61df8e00613b0696f1
|