bir dosya nesnesinin readlines
yöntemi kullanabilirsiniz.
with open('topsites.txt') as f:
testsite_array=f.readlines()
veya basitçe list
kullanın bu readlines
kullanarak aynıdır ancak tek fark, bizim readlines
için isteğe bağlı boy argüman iletebilirsiniz şudur:
with open('topsites.txt') as f:
testsite_array=list(f)
yardım file.readlines
tarih:
In [46]: file.readlines?
Type: method_descriptor
String Form:<method 'readlines' of 'file' objects>
Namespace: Python builtin
Docstring:
readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned.