How to compare lines from a text file in Python?
hope this is not a trivial question since I'm new to Python. I have a text file, and I need to compare the first line with all the following ones, than the second line with all the following ones, etc. If it was a list I'd just make two for loops, but I don't know how to start reading a file from the line after the one that needs to be compared. Could someone help me?作者: SnowyNe 的来源 发布者： 2017 年 12 月 27 日
This will give you a list of all the lines:
作者: it's-yer-boy-chet 发布者: 2017 年 12 月 27 日
with open(path_to_file) as f: list_of_lines = f.readlines()
作者: PedroNeves 发布者: 2017 年 12 月 27 日
for line in f1: for line_aux in f2: compare the two lines