@@ -385,6 +385,10 @@ msgid ""
385385"file has been reached, ``f.read()`` will return an empty string (``''``). "
386386"::"
387387msgstr ""
388+ "要读取文件内容,请调用 ``f.read(size)`` ,它会读取一些数据并将其作为字符串(在文本模式下)或字节对象(在二进制模式下)返回。 "
389+ "*size* 是一个可选的数字参数。当 *size* "
390+ "被省略或者为负的时候,将读取并返回文件的整个内容;如果文件的大小是机器内存的两倍,那么就可能出现问题。否则,最多读取并返回 *size* "
391+ "字节的内容,如果已到达文件末尾,``f.read()`` 将返回一个空字符串 (``''``)。 ::"
388392
389393#: ../../tutorial/inputoutput.rst:369
390394msgid ""
@@ -395,37 +399,41 @@ msgid ""
395399"end of the file has been reached, while a blank line is represented by "
396400"``'\\ n'``, a string containing only a single newline. ::"
397401msgstr ""
402+ "``f.readline()`` "
403+ "从文件中读取一行;换行符(``\\ n``)留在字符串的末尾,如果文件不以换行符结尾,则在文件的最后一行省略。这使得返回值明确无误;如果 "
404+ "``f.readline()`` 返回一个空的字符串,则表示已经到达了文件末尾,而空行使用 ``'\\ n'`` 表示,该字符串只包含一个换行符。::"
398405
399406#: ../../tutorial/inputoutput.rst:383
400407msgid ""
401408"For reading lines from a file, you can loop over the file object. This is "
402409"memory efficient, fast, and leads to simple code::"
403- msgstr ""
410+ msgstr "要从文件中读取行,你可以循环遍历文件对象。这是内存高效,快速的,并简化代码:: "
404411
405412#: ../../tutorial/inputoutput.rst:392
406413msgid ""
407414"If you want to read all the lines of a file in a list you can also use "
408415"``list(f)`` or ``f.readlines()``."
409- msgstr ""
416+ msgstr "如果你想以列表的形式读取文件中的所有行,你也可以使用 ``list(f)`` 或 ``f.readlines()``。 "
410417
411418#: ../../tutorial/inputoutput.rst:395
412419msgid ""
413420"``f.write(string)`` writes the contents of *string* to the file, returning "
414421"the number of characters written. ::"
415- msgstr ""
422+ msgstr "``f.write(string)`` 会把 *string* 的内容写入到文件中,并返回写入的字符数。:: "
416423
417424#: ../../tutorial/inputoutput.rst:401
418425msgid ""
419426"Other types of objects need to be converted -- either to a string (in text "
420427"mode) or a bytes object (in binary mode) -- before writing them::"
421- msgstr ""
428+ msgstr "在写入其他类型的对象之前,需要先把它们转化为字符串(在文本模式下)或者字节对象(在二进制模式下):: "
422429
423430#: ../../tutorial/inputoutput.rst:409
424431msgid ""
425432"``f.tell()`` returns an integer giving the file object's current position in"
426433" the file represented as number of bytes from the beginning of the file when"
427434" in binary mode and an opaque number when in text mode."
428435msgstr ""
436+ "``f.tell()`` 返回一个整数,给出文件对象在文件中的当前位置,表示为二进制模式下时从文件开始的字节数,以及文本模式下的不透明数字。"
429437
430438#: ../../tutorial/inputoutput.rst:413
431439msgid ""
@@ -437,6 +445,9 @@ msgid ""
437445"*from_what* can be omitted and defaults to 0, using the beginning of the "
438446"file as the reference point. ::"
439447msgstr ""
448+ "要改变文件对象的位置,请使用 ``f.seek(offset, from_what)`` 。通过向参考点添加 *offset* 来计算位置;参考点由 "
449+ "*from_what* 参数指定。*from_what*值为0时,表示从文件开头开始,1 表示从当前位置,2 "
450+ "表示把文件末尾作为参考点。*from_what* 可以省略,默认为0,即使用文件开头作为参考点。::"
440451
441452#: ../../tutorial/inputoutput.rst:432
442453msgid ""
0 commit comments