Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f7955af6
Kaydet (Commit)
f7955af6
authored
Haz 28, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Note that file objects are iterable.
üst
85ca29a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
tut.tex
Doc/tut/tut.tex
+15
-0
No files found.
Doc/tut/tut.tex
Dosyayı görüntüle @
f7955af6
...
...
@@ -3166,6 +3166,21 @@ entire file in memory. Only complete lines will be returned.
[
'This is the first line of the file.
\n
', 'Second line of the file
\n
'
]
\end
{
verbatim
}
An alternate approach to reading lines is to loop over the file object.
This is memory efficient, fast, and leads to simpler code:
\begin
{
verbatim
}
>>> for line in f:
print line,
This is the first line of the file.
Second line of the file
\end
{
verbatim
}
The alternative approach is simpler but does not provide as fine
-
grained
control. Since the two approaches manage line buffering differently,
they should not be mixed.
\code
{
f.write
(
\var
{
string
}
)
}
writes the contents of
\var
{
string
}
to
the file, returning
\code
{
None
}
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment