<bdo id='siPoU'></bdo><ul id='siPoU'></ul>

    1. <i id='siPoU'><tr id='siPoU'><dt id='siPoU'><q id='siPoU'><span id='siPoU'><b id='siPoU'><form id='siPoU'><ins id='siPoU'></ins><ul id='siPoU'></ul><sub id='siPoU'></sub></form><legend id='siPoU'></legend><bdo id='siPoU'><pre id='siPoU'><center id='siPoU'></center></pre></bdo></b><th id='siPoU'></th></span></q></dt></tr></i><div id='siPoU'><tfoot id='siPoU'></tfoot><dl id='siPoU'><fieldset id='siPoU'></fieldset></dl></div>

      1. <small id='siPoU'></small><noframes id='siPoU'>

        <legend id='siPoU'><style id='siPoU'><dir id='siPoU'><q id='siPoU'></q></dir></style></legend>
        <tfoot id='siPoU'></tfoot>

        内置 open 函数中模式 a、a+、w、w+ 和 r+ 的区别?

        时间:2024-04-22
        <tfoot id='kkZe7'></tfoot>

        <small id='kkZe7'></small><noframes id='kkZe7'>

          • <bdo id='kkZe7'></bdo><ul id='kkZe7'></ul>
            • <i id='kkZe7'><tr id='kkZe7'><dt id='kkZe7'><q id='kkZe7'><span id='kkZe7'><b id='kkZe7'><form id='kkZe7'><ins id='kkZe7'></ins><ul id='kkZe7'></ul><sub id='kkZe7'></sub></form><legend id='kkZe7'></legend><bdo id='kkZe7'><pre id='kkZe7'><center id='kkZe7'></center></pre></bdo></b><th id='kkZe7'></th></span></q></dt></tr></i><div id='kkZe7'><tfoot id='kkZe7'></tfoot><dl id='kkZe7'><fieldset id='kkZe7'></fieldset></dl></div>
            • <legend id='kkZe7'><style id='kkZe7'><dir id='kkZe7'><q id='kkZe7'></q></dir></style></legend>

                  <tbody id='kkZe7'></tbody>

                  本文介绍了内置 open 函数中模式 a、a+、w、w+ 和 r+ 的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在python内置的open函数中,具体有什么区别在 waw+a+r+ 模式之间?

                  In the python built-in open function, what is the exact difference between the modes w, a, w+, a+, and r+?

                  特别是,文档暗示所有这些都将允许写入文件,并说它打开文件是为了附加"、写入"和更新",但没有定义这些术语的含义.

                  In particular, the documentation implies that all of these will allow writing to the file, and says that it opens the files for "appending", "writing", and "updating" specifically, but does not define what these terms mean.

                  推荐答案

                  打开方式与C标准库函数fopen()完全相同.

                  The opening modes are exactly the same as those for the C standard library function fopen().

                  BSD fopen 手册页 将它们定义如下:

                  The BSD fopen manpage defines them as follows:

                   The argument mode points to a string beginning with one of the following
                   sequences (Additional characters may follow these sequences.):
                  
                   ``r''   Open text file for reading.  The stream is positioned at the
                           beginning of the file.
                  
                   ``r+''  Open for reading and writing.  The stream is positioned at the
                           beginning of the file.
                  
                   ``w''   Truncate file to zero length or create text file for writing.
                           The stream is positioned at the beginning of the file.
                  
                   ``w+''  Open for reading and writing.  The file is created if it does not
                           exist, otherwise it is truncated.  The stream is positioned at
                           the beginning of the file.
                  
                   ``a''   Open for writing.  The file is created if it does not exist.  The
                           stream is positioned at the end of the file.  Subsequent writes
                           to the file will always end up at the then current end of file,
                           irrespective of any intervening fseek(3) or similar.
                  
                   ``a+''  Open for reading and writing.  The file is created if it does not
                           exist.  The stream is positioned at the end of the file.  Subse-
                           quent writes to the file will always end up at the then current
                           end of file, irrespective of any intervening fseek(3) or similar.
                  

                  这篇关于内置 open 函数中模式 a、a+、w、w+ 和 r+ 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用不同的 Python 版本和 virtualenv 下一篇:为什么我的函数输出打印出“无"?

                  相关文章

                    <bdo id='II6CH'></bdo><ul id='II6CH'></ul>
                  <legend id='II6CH'><style id='II6CH'><dir id='II6CH'><q id='II6CH'></q></dir></style></legend>

                1. <small id='II6CH'></small><noframes id='II6CH'>

                    <i id='II6CH'><tr id='II6CH'><dt id='II6CH'><q id='II6CH'><span id='II6CH'><b id='II6CH'><form id='II6CH'><ins id='II6CH'></ins><ul id='II6CH'></ul><sub id='II6CH'></sub></form><legend id='II6CH'></legend><bdo id='II6CH'><pre id='II6CH'><center id='II6CH'></center></pre></bdo></b><th id='II6CH'></th></span></q></dt></tr></i><div id='II6CH'><tfoot id='II6CH'></tfoot><dl id='II6CH'><fieldset id='II6CH'></fieldset></dl></div>
                    1. <tfoot id='II6CH'></tfoot>