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
6b4fa776
Kaydet (Commit)
6b4fa776
authored
Agu 30, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
rewrite and move open() docs only to functions.rst
üst
4e4ffb11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
33 deletions
+35
-33
functions.rst
Doc/library/functions.rst
+35
-33
io.rst
Doc/library/io.rst
+0
-0
No files found.
Doc/library/functions.rst
Dosyayı görüntüle @
6b4fa776
...
@@ -712,36 +712,37 @@ are always available. They are listed here in alphabetical order.
...
@@ -712,36 +712,37 @@ are always available. They are listed here in alphabetical order.
========= ===============================================================
========= ===============================================================
The default mode is ``'r'`` (open for reading text, synonym of ``'rt'``).
The default mode is ``'r'`` (open for reading text, synonym of ``'rt'``).
For binary read-write access, the mode ``'w+b'`` opens and truncates the
For binary read-write access, the mode ``'w+b'`` opens and truncates the
file
file to 0 bytes, while
``'r+b'`` opens the file without truncation.
to 0 bytes.
``'r+b'`` opens the file without truncation.
As mentioned in the
`overview`_
, Python distinguishes between binary
As mentioned in the
:ref:`io-overview`
, Python distinguishes between binary
and text I/O. Files opened in binary mode (including ``'b'`` in the
and text I/O. Files opened in binary mode (including ``'b'`` in the
*mode*
*mode* argument) return contents as :class:`bytes` objects without
argument) return contents as :class:`bytes` objects without any decoding. In
any decoding. In text mode (the default, or when ``'t'``
text mode (the default, or when ``'t'`` is included in the *mode* argument),
is included in the *mode* argument), the contents of the file are
the contents of the file are returned as :class:`str`, the bytes having been
returned as strings, the bytes having been first decoded using a
first decoded using a platform-dependent encoding or using the specified
platform-dependent encoding or using the specified
*encoding* if given.
*encoding* if given.
.. note::
.. note::
Python doesn't depend on the underlying operating system's notion
of text files; all the the processing is done by Python itself, and
is therefore platform-independent.
*buffering* is an optional integer used to set the buffering policy.
Python doesn't depend on the underlying operating system's notion of text
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
files; all the the processing is done by Python itself, and is therefore
line buffering (only usable in text mode), and an integer > 1 to indicate
platform-independent.
the size of a fixed-size chunk buffer. When no *buffering* argument is
given, the default buffering policy works as follows:
* Binary files are buffered in fixed-size chunks; the size of the buffer
*buffering* is an optional integer used to set the buffering policy. Pass 0
is chosen using a heuristic trying to determine the underlying device's
to switch buffering off (only allowed in binary mode), 1 to select line
"block size" and falling back on :attr:`DEFAULT_BUFFER_SIZE`.
buffering (only usable in text mode), and an integer > 1 to indicate the size
On many systems, the buffer will typically be 4096 or 8192 bytes long.
of a fixed-size chunk buffer. When no *buffering* argument is given, the
default buffering policy works as follows:
* "Interactive" text files (files for which :meth:`isatty` returns True)
* Binary files are buffered in fixed-size chunks; the size of the buffer is
use line buffering. Other text files use the policy described above
chosen using a heuristic trying to determine the underlying device's "block
for binary files.
size" and falling back on :attr:`io.DEFAULT_BUFFER_SIZE`. On many systems,
the buffer will typically be 4096 or 8192 bytes long.
* "Interactive" text files (files for which :meth:`isatty` returns True) use
line buffering. Other text files use the policy described above for binary
files.
*encoding* is the name of the encoding used to decode or encode the file.
*encoding* is the name of the encoding used to decode or encode the file.
This should only be used in text mode. The default encoding is platform
This should only be used in text mode. The default encoding is platform
...
@@ -784,16 +785,17 @@ are always available. They are listed here in alphabetical order.
...
@@ -784,16 +785,17 @@ are always available. They are listed here in alphabetical order.
closed. If a filename is given *closefd* has no effect and must be ``True``
closed. If a filename is given *closefd* has no effect and must be ``True``
(the default).
(the default).
The type of file object returned by the :func:`
.
open` function depends on the
The type of file object returned by the :func:`open` function depends on the
mode. When :func:`
.
open` is used to open a file in a text mode (``'w'``,
mode. When :func:`open` is used to open a file in a text mode (``'w'``,
``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of
``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of
:class:`TextIOBase` (specifically :class:`TextIOWrapper`). When used to open
:class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used
a file in a binary mode with buffering, the returned class is a subclass of
to open a file in a binary mode with buffering, the returned class is a
:class:`BufferedIOBase`. The exact class varies: in read binary mode, it
subclass of :class:`io.BufferedIOBase`. The exact class varies: in read
returns a :class:`BufferedReader`; in write binary and append binary modes,
binary mode, it returns a :class:`io.BufferedReader`; in write binary and
it returns a :class:`BufferedWriter`, and in read/write mode, it returns a
append binary modes, it returns a :class:`io.BufferedWriter`, and in
:class:`BufferedRandom`. When buffering is disabled, the raw stream, a
read/write mode, it returns a :class:`io.BufferedRandom`. When buffering is
subclass of :class:`RawIOBase`, :class:`FileIO`, is returned.
disabled, the raw stream, a subclass of :class:`io.RawIOBase`,
:class:`io.FileIO`, is returned.
.. index::
.. index::
single: line-buffered I/O
single: line-buffered I/O
...
...
Doc/library/io.rst
Dosyayı görüntüle @
6b4fa776
This diff is collapsed.
Click to expand it.
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