Corepython the Nineth Chapter exercises

Source: Internet
Author: User

9-6. File comparison. Write a program that compares two text files, and if different, give the line number and column number of the first different place.
1Fa=raw_input ("Please input 1st file ' s path:")2Fb=raw_input ("Please input 2nd file ' s path:")3File_a=open (FA,'R')4File_b=open (FB,'R')5A_rl=File_a.readlines ()6B_rl=File_b.readlines ()7 file_a.close ()8 file_b.close ()9Minrow=min (Len (A_RL), Len (B_RL))#get the minimum number of rowsTen  forRinchRange (minrow+1): One     ifa_rl[r]!=B_rl[r]: A         Print 'row:%d'% r+1 -         #the minimum number of columns to get the first one not to walk -Mincol=min (len (a_rl[r]), Len (B_rl[r])) the          forCinchRange (mincol+1): -             ifA_RL[R][C]! =B_rl[r][c]: -                 Print 'column:%d'% c+1 -                  Break +          Break
View Code

Corepython the Nineth Chapter exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.