<p>以下是详细的区别:</p>
<blockquote>
<p>``r'' Open text file for reading. The stream is positioned at the
beginning of the file.</p>
<p>``r+'' Open for reading and writing. The stream is positioned at
the
beginning of the file.</p>
<p>``w'' Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.</p>
<p>``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.</p>
<p>``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.</p>
<p>``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.</p>
</blockquote>
<p>来自python文档-<a href="http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files:-" rel="nofollow noreferrer">http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files:-</a></p>
<blockquote>
<p>On Windows, 'b' appended to the mode opens the file in binary mode, so
there are also modes like 'rb', 'wb', and 'r+b'. Python on Windows
makes a distinction between text and binary files; the end-of-line
characters in text files are automatically altered slightly when data
is read or written. This behind-the-scenes modification to file data
is fine for ASCII text files, but it’ll corrupt binary data like that
in JPEG or EXE files. Be very careful to use binary mode when reading
and writing such files. On Unix, it doesn’t hurt to append a 'b' to
the mode, so you can use it platform-independently for all binary
files.</p>
</blockquote>
<p>因此,如果您使用的是<code>w</code>模式,那么您实际上是在尝试创建一个文件,而您可能没有这样做的权限。<code>r+</code>是合适的选择。</p>
<p>如果您还不知道<code>.picasi.ini</code>存在与否,并且您的windows用户在该目录中具有文件创建权限,并且您希望附加新信息而不是从文件的开头开始(也称为“附加”),则<code>a+</code>将是适当的选择。</p>
<p>文件是否隐藏与此无关。</p>