Need to create a program in python 3.0. The program should compare the source file with the text with another text file. It is necessary to break the text into lines, if more than 50 repeat.
Closed due to the fact that off-topic participants Xander , aleksandr barakin , Kromster , andreymal , Timofei Bondarev Jun 1 '17 at 13:24 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- "The message contains only the text of the task, in which there is no description of the problem, or the question is purely formal (" how do I do this task ") . To reopen the question, add a description of the specific problem, explain what does not work, what you see the problem. " - Kromster, Timofei Bondarev
- 3Alexander question what is it? - Alexander
|
2 answers
In general, you can compare 2 files like this:
In [2]: open(r'C:\Users\user\Desktop\DKOM-Rootkit-master\numbers.txt').read() == open(r'C:\Users\user\Desktop\DKOM-Rootkit-master\text.txt').read() Out[2]: True |
def is_different_files(file1, file2): with open(file1) as f1, open(file2) as f2: # открыть файлы на чтение for line1, line2 in zip(f1, f2): # читать построчно оба файла if not line1 == line2: # сравниваем строки return True # разные if is_different_files('test1.log', 'test2.log'): print('файлы разные') - If the lines are not equal to the number? - Pavel Durmanov
|