It makes little difference but it is slightly cleaner to use enumerate
rather than making your own counter variable.
for i, row in enumerate(reader):
if i == N:
print("This is the line.")
print(row)
break
You can also use itertools.islice
which is designed for this type of scenario - accessing a particular slice of an iterable without reading the whole thing into memory. It should be a bit more efficient than looping through the unwanted rows.
with open(path, 'r') as f:
N = int(input('What line do you need? > '))
print("This is the line.")
print(next(itertools.islice(csv.reader(f), N, None)))
But if your CSV file is small, just read the entire thing into a list, which you can then access with an index in the normal way. This also has the advantage that you can access several different rows in random order without having to reset the csv reader.
my_csv_data = list(reader)
print(my_csv_data[N])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…