Zeile für Zeile eine Datei in Elemente eines Arrays in Python einlesen [duplizieren]
Diese Frage hat hier bereits eine Antwort:
Wie liest man eine Datei Zeile für Zeile in eine Liste ein? 34 AntwortenIn Ruby kann ich also Folgendes tun:
testsite_array = Array.new
y=0
File.open('topsites.txt').each do |line|
testsite_array[y] = line
y=y+1
end
Wie würde man das in Python machen?