python脚本比较两个文件,仅比较不匹配的字符串

时间:2018-09-19 06:11:02

标签: python scripting

“ file1.txt”包含以下几行:

environment=sit  
javahome=/var/tmp/java 
tcinstnace=/opt/apps  
passowrd=asdf12  

“ file2.txt”包含:

environment=qa 
tcinstnace=/opt/apps  
certpath=/opt/apps  
javahome=/opt/apps

我想比较两个文件并打印两个文件之间的差异,例如(忽略匹配的行)

file1                          file2 
environment=sit`               environment=qa  
javahome=/var/tmp/java`        javahome=/opt/apps` 
passowrd=asdf12`               missing
missing`                       certpath=/opt/apps

0 个答案:

没有答案