⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os-file-dir.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:

<P>
<dl><dt><b><a name='l2h-962'><tt class='function'>readlink</tt></a></b> (<var>path</var>)
<dd>
Return a string representing the path to which the symbolic link
points.
Availability: Unix.
</dl>

<P>
<dl><dt><b><a name='l2h-963'><tt class='function'>remove</tt></a></b> (<var>path</var>)
<dd>
Remove the file <var>path</var>.  See <tt class="function">rmdir()</tt> below to remove a
directory.  This is identical to the <tt class="function">unlink()</tt> function
documented below.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-964'><tt class='function'>removedirs</tt></a></b> (<var>path</var>)
<dd>

Recursive directory removal function.  Works like
<tt class="function">rmdir()</tt> except that, if the leaf directory is
successfully removed, directories corresponding to rightmost path
segments will be pruned way until either the whole path is consumed or
an error is raised (which is ignored, because it generally means that
a parent directory is not empty).  Throws an <tt class="exception">error</tt>
exception if the leaf directory could not be successfully removed.

New in version 1.5.2.

</dl>

<P>
<dl><dt><b><a name='l2h-965'><tt class='function'>rename</tt></a></b> (<var>src, dst</var>)
<dd>
Rename the file or directory <var>src</var> to <var>dst</var>.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-966'><tt class='function'>renames</tt></a></b> (<var>old, new</var>)
<dd>
Recursive directory or file renaming function.
Works like <tt class="function">rename()</tt>, except creation of any intermediate
directories needed to make the new pathname good is attempted first.
After the rename, directories corresponding to rightmost path segments
of the old name will be pruned away using <tt class="function">removedirs()</tt>.

<P>
Note: this function can fail with the new directory structure made if
you lack permissions needed to remove the leaf directory or file.

New in version 1.5.2.

</dl>

<P>
<dl><dt><b><a name='l2h-967'><tt class='function'>rmdir</tt></a></b> (<var>path</var>)
<dd>
Remove the directory <var>path</var>.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-968'><tt class='function'>stat</tt></a></b> (<var>path</var>)
<dd>
Perform a <tt class="cfunction">stat()</tt> system call on the given path.  The
return value is a tuple of at least 10 integers giving the most
important (and portable) members of the <i>stat</i> structure, in the
order
<code>st_mode</code>,
<code>st_ino</code>,
<code>st_dev</code>,
<code>st_nlink</code>,
<code>st_uid</code>,
<code>st_gid</code>,
<code>st_size</code>,
<code>st_atime</code>,
<code>st_mtime</code>,
<code>st_ctime</code>.
More items may be added at the end by some implementations.  Note that
on the Macintosh, the time values are floating point values, like all
time values on the Macintosh.
(On MS Windows, some items are filled with dummy values.)
Availability: Macintosh, Unix, Windows.

<P>
Note: The standard module <tt class='module'><a href="module-stat.html" tppabs="http://www.python.org/doc/current/lib/module-stat.html">stat</a></tt> defines
functions and constants that are useful for extracting information
from a <tt class="ctype">stat</tt> structure.
</dl>

<P>
<dl><dt><b><a name='l2h-969'><tt class='function'>statvfs</tt></a></b> (<var>path</var>)
<dd>
Perform a <tt class="cfunction">statvfs()</tt> system call on the given path.  The
return value is a tuple of 10 integers giving the most common
members of the <tt class="ctype">statvfs</tt> structure, in the order
<code>f_bsize</code>,
<code>f_frsize</code>,
<code>f_blocks</code>,
<code>f_bfree</code>,
<code>f_bavail</code>,
<code>f_files</code>,
<code>f_ffree</code>,
<code>f_favail</code>,
<code>f_flag</code>,
<code>f_namemax</code>.
Availability: Unix.

<P>
Note: The standard module <tt class="module">statvfs</tt>
defines constants that are useful for extracting information
from a <tt class="ctype">statvfs</tt> structure.
</dl>

<P>
<dl><dt><b><a name='l2h-970'><tt class='function'>symlink</tt></a></b> (<var>src, dst</var>)
<dd>
Create a symbolic link pointing to <var>src</var> named <var>dst</var>.
Availability: Unix.
</dl>

<P>
<dl><dt><b><a name='l2h-971'><tt class='function'>tempnam</tt></a></b> (<big>[</big><var>dir</var><big>[</big><var>, prefix</var><big>]</big><big>]</big>)
<dd>
Return a unique path name that is reasonable for creating a temporary
file.  This will be an absolute path that names a potential directory
entry in the directory <var>dir</var> or a common location for temporary
files if <var>dir</var> is omitted or <code>None</code>.  If given and not
<code>None</code>, <var>prefix</var> is used to provide a short prefix to the
filename.  Applications are responsible for properly creating and
managing files created using paths returned by <tt class="function">tempnam()</tt>;
no automatic cleanup is provided.
</dl>

<P>
<dl><dt><b><a name='l2h-972'><tt class='function'>tmpnam</tt></a></b> ()
<dd>
Return a unique path name that is reasonable for creating a temporary
file.  This will be an absolute path that names a potential directory
entry in a common location for temporary files.  Applications are
responsible for properly creating and managing files created using
paths returned by <tt class="function">tmpnam()</tt>; no automatic cleanup is
provided.
</dl>

<P>
<dl><dt><b><a name='l2h-973'><tt>TMP_MAX</tt></a></b>
<dd>
The maximum number of unique names that <tt class="function">tmpnam()</tt> will
generate before reusing names.
</dl>

<P>
<dl><dt><b><a name='l2h-974'><tt class='function'>unlink</tt></a></b> (<var>path</var>)
<dd>
Remove the file <var>path</var>.  This is the same function as
<tt class="function">remove()</tt>; the <tt class="function">unlink()</tt> name is its traditional
Unix name.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-975'><tt class='function'>utime</tt></a></b> (<var>path, times</var>)
<dd>
Set the access and modified times of the file specified by <var>path</var>.
If <var>times</var> is <code>None</code>, then the file's access and modified
times are set to the current time.  Otherwise, <var>times</var> must be a
2-tuple of numbers, of the form <code>(<var>atime</var>, <var>mtime</var>)</code>
which is used to set the access and modified times, respectively.

Changed in version 2.0:
added support for <code>None</code> for <var>times</var>.

Availability: Macintosh, Unix, Windows.
</dl>

<P>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="os-fd-ops.html" tppabs="http://www.python.org/doc/current/lib/os-fd-ops.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="os-process.html" tppabs="http://www.python.org/doc/current/lib/os-process.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="os-fd-ops.html" tppabs="http://www.python.org/doc/current/lib/os-fd-ops.html">6.1.3 File Descriptor Operations</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">6.1 os  </A>
<b class="navlabel">Next:</b> <a class="sectref" href="os-process.html" tppabs="http://www.python.org/doc/current/lib/os-process.html">6.1.5 Process Management</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -