python比较两个文本文件,将输出打印到另一个文件

时间:2018-09-14 22:22:59

标签: python list

file1.txt

neighbor 192.168.3.1 remote-as 200
neighbor 192.168.4.1 remote-as 300
neighbor 192.168.15.1 remote-as 400
neighbor 192.168.16.1 remote-as 500
neighbor 20.249.208.165 remote-as 200
neighbor 80.249.208.165 remote-as 100
neighbor 192.168.5.1 remote-as 400

file2.txt

neighbor 26.24.1.165 remote-as 200
neighbor 90.239.208.165 remote-as 100
neighbor 192.168.3.1 remote-as 200
neighbor 192.168.4.1 remote-as 300
neighbor 192.168.5.1 remote-as 400
neighbor 192.168.6.1 remote-as 500
neighbor 192.168.15.1 remote-as 400
neighbor 192.168.16.1 remote-as 500

我有这两个文件!!!! 我想将file1.txt的每一行与file2.txt的所有行进行比较,并打印出确实匹配的行。

我尝试了很多方法,有时候在使用for循环之外的变量时遇到问题!谁能帮我 !!!谢谢

0 个答案:

没有答案