Código Python:
Ver originalwith open("temp.txt", "r") as f:
lineas = f.readlines()
print lineas[2]
with open("temp.txt", "r") as f:
text = f.read()
lineas = text.split("\n")
print lineas[2]
with open("temp.txt", "r") as f:
for i, linea in enumerate(f, start=1):
if i == 3:
print linea
break
with open("temp.txt", "r") as f:
next(f)
next(f)
print next(f)
Bueno, aquí hay al menos 4 maneras diferentes de leer la tercera linea de un archivo. (Claro obvia sin validar nada)