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
e34f8a94
Kaydet (Commit)
e34f8a94
authored
Eyl 15, 2012
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#15932: use with statement in csv doc examples. Patch by Dario Bertini.
üst
1e7ee9df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
csv.rst
Doc/library/csv.rst
+15
-13
No files found.
Doc/library/csv.rst
Dosyayı görüntüle @
e34f8a94
...
@@ -71,9 +71,10 @@ The :mod:`csv` module defines the following functions:
...
@@ -71,9 +71,10 @@ The :mod:`csv` module defines the following functions:
A short usage example::
A short usage example::
>>> import csv
>>> import csv
>>> spamReader = csv.reader(open('eggs.csv', newline=''), delimiter=' ', quotechar='|')
>>> with open('eggs.csv', newline='') as csvfile:
>>> for row in spamReader:
... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
... print(', '.join(row))
... for row in spamreader:
... print(', '.join(row))
Spam, Spam, Spam, Spam, Spam, Baked Beans
Spam, Spam, Spam, Spam, Spam, Baked Beans
Spam, Lovely Spam, Wonderful Spam
Spam, Lovely Spam, Wonderful Spam
...
@@ -99,11 +100,12 @@ The :mod:`csv` module defines the following functions:
...
@@ -99,11 +100,12 @@ The :mod:`csv` module defines the following functions:
A short usage example::
A short usage example::
>>> import csv
import csv
>>> spamWriter = csv.writer(open('eggs.csv', 'w', newline=''), delimiter=' ',
with open('eggs.csv', 'w', newline='') as csvfile:
... quotechar='|', quoting=csv.QUOTE_MINIMAL)
spamwriter = csv.writer(csvfile, delimiter=' ',
>>> spamWriter.writerow(['Spam'] * 5 + ['Baked Beans'])
quotechar='|', quoting=csv.QUOTE_MINIMAL)
>>> spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
.. function:: register_dialect(name[, dialect], **fmtparams)
.. function:: register_dialect(name[, dialect], **fmtparams)
...
@@ -221,11 +223,11 @@ The :mod:`csv` module defines the following classes:
...
@@ -221,11 +223,11 @@ The :mod:`csv` module defines the following classes:
An example for :class:`Sniffer` use::
An example for :class:`Sniffer` use::
csvfile = open("example.csv")
with open('example.csv') as csvfile:
dialect = csv.Sniffer().sniff(csvfile.read(1024))
dialect = csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
csvfile.seek(0)
reader = csv.reader(csvfile, dialect)
reader = csv.reader(csvfile, dialect)
# ... process CSV file contents here ...
# ... process CSV file contents here ...
The :mod:`csv` module defines the following constants:
The :mod:`csv` module defines the following constants:
...
...
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