@@ -99,7 +99,7 @@ msgstr ""
9999msgid ""
100100"The easiest way to create a text stream is with :meth:`open`, optionally "
101101"specifying an encoding::"
102- msgstr "创建文本流的最简单方式是使用 :meth:`open`,并可选择指定编码格式::"
102+ msgstr "创建文本流的最简单方式是通过 :meth:`open`,并可选择指定编码格式::"
103103
104104#: ../../library/io.rst:61
105105msgid "f = open(\" myfile.txt\" , \" r\" , encoding=\" utf-8\" )"
@@ -139,7 +139,7 @@ msgstr ""
139139msgid ""
140140"The easiest way to create a binary stream is with :meth:`open` with ``'b'`` "
141141"in the mode string::"
142- msgstr "创建二进制流的最简单方式是使用 :meth:`open` 并在模式字符串中使用 ``'b'``::"
142+ msgstr "创建二进制流的最简单方式是通过 :meth:`open` 并在模式字符串中使用 ``'b'``::"
143143
144144#: ../../library/io.rst:83
145145msgid "f = open(\" myfile.jpg\" , \" rb\" )"
@@ -1554,6 +1554,8 @@ msgid ""
15541554"``encoding=\" locale\" `` can be used to specify the current locale's encoding"
15551555" explicitly. See :ref:`io-text-encoding` for more information."
15561556msgstr ""
1557+ "*encoding* 给出将被用于编码或解码流的编码格式。 该参数值默认为 :func:`locale.getencoding`。 可以使用 "
1558+ "``encoding=\" locale\" `` 来显式地指定当前语言区域的编码格式。 详情参见 :ref:`io-text-encoding`。"
15571559
15581560#: ../../library/io.rst:957
15591561msgid ""
@@ -1814,6 +1816,19 @@ msgid ""
18141816"# .getvalue() will now raise an exception.\n"
18151817"output.close()"
18161818msgstr ""
1819+ "import io\n"
1820+ "\n"
1821+ "output = io.StringIO()\n"
1822+ "output.write('First line.\\ n')\n"
1823+ "print('Second line.', file=output)\n"
1824+ "\n"
1825+ "# 提取文件内容 -- 这将为\n"
1826+ "# 'First line.\\ nSecond line.\\ n'\n"
1827+ "contents = output.getvalue()\n"
1828+ "\n"
1829+ "# 关闭对象并丢弃内存缓冲区 --\n"
1830+ "# 现在 .getvalue() 将引发一个异常。\n"
1831+ "output.close()"
18171832
18181833#: ../../library/io.rst:1126
18191834msgid ""
@@ -1923,6 +1938,8 @@ msgid ""
19231938"standard streams and therefore affects the built-in :func:`print` function "
19241939"as well."
19251940msgstr ""
1941+ "上面的代码将显式地扩展到文本文件,因为 :func:`open` 函数将把缓冲的对象包装在 :class:`TextIOWrapper` 中。 "
1942+ "这包括标准流因而也会影响内置的 :func:`print` 函数。"
19261943
19271944#: ../../library/io.rst:24
19281945msgid "file object"
0 commit comments