import os

def compare_linelist(filename1,filename2):  
     
print "compare_linelist (%s,%s)"%(filename1,filename2)
     f1
=open(filename1,"r")
     f2
=open(filename2,"r")
     line1
=f1.readline().strip()
     line2
=f2.readline().strip()
   
     nSucc
=0
     nCount
=0
     
while True:
         
if line1=='' or  line2=='':            
             
break
         
print "%s : %s"%(line1,line2) 
         nCount
=nCount+1
         
if line1==line2:
             nSucc
=nSucc+1
         line1
=f1.readline().strip()
         line2
=f2.readline().strip()   
 
     rate
=float(nSucc)/float(nCount)*100        
     
     f1.close()
     f2.close()   
     
return (nCount,nSucc,rate)

if __name__=='__main__':
    work_directory
="E:\\py\\WinPython-32bit-2.7.6.4\\study"
    os.chdir(work_directory)
    
print "current directory:", work_directory    
    filename1
="1.txt"
    filename2
="2.txt"    
    result
=compare_linelist(filename1,filename2)
    
print("nCount:%d nSucc:%d rate:%d%%")%result