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

📄 os-file-dir.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>6.1.4 Files and Directories </title>
<META NAME="description" CONTENT="6.1.4 Files and Directories ">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="os-process.html" tppabs="http://www.python.org/doc/current/lib/os-process.html">
<LINK REL="previous" href="os-fd-ops.html" tppabs="http://www.python.org/doc/current/lib/os-fd-ops.html">
<LINK REL="up" href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">
<LINK REL="next" href="os-process.html" tppabs="http://www.python.org/doc/current/lib/os-process.html">
</head>
<body>
<DIV CLASS="navigation"><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>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H2>
<BR>
6.1.4 Files and Directories 
</H2>

<P>
<dl><dt><b><a name='l2h-945'><tt class='function'>access</tt></a></b> (<var>path, mode</var>)
<dd>
Check read/write/execute permissions for this process or existence of
file <var>path</var>.  <var>mode</var> should be <tt class="constant">F_OK</tt> to test the
existence of <var>path</var>, or it can be the inclusive OR of one or more
of <tt class="constant">R_OK</tt>, <tt class="constant">W_OK</tt>, and <tt class="constant">X_OK</tt> to test
permissions.  Return <code>1</code> if access is allowed, <code>0</code> if not.
See the Unix man page <span class='manpage'><i>access</i>(2)</span> for more information.
Availability: Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-946'><tt>F_OK</tt></a></b>
<dd>
  Value to pass as the <var>mode</var> parameter of <tt class="function">access()</tt> to
  test the existence of <var>path</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-947'><tt>R_OK</tt></a></b>
<dd>
  Value to include in the <var>mode</var> parameter of <tt class="function">access()</tt>
  to test the readability of <var>path</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-948'><tt>W_OK</tt></a></b>
<dd>
  Value to include in the <var>mode</var> parameter of <tt class="function">access()</tt>
  to test the writability of <var>path</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-949'><tt>X_OK</tt></a></b>
<dd>
  Value to include in the <var>mode</var> parameter of <tt class="function">access()</tt>
  to determine if <var>path</var> can be executed.
</dl>

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

Change the current working directory to <var>path</var>.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-951'><tt class='function'>getcwd</tt></a></b> ()
<dd>
Return a string representing the current working directory.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-952'><tt class='function'>chmod</tt></a></b> (<var>path, mode</var>)
<dd>
Change the mode of <var>path</var> to the numeric <var>mode</var>.
Availability: Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-953'><tt class='function'>chown</tt></a></b> (<var>path, uid, gid</var>)
<dd>
Change the owner and group id of <var>path</var> to the numeric <var>uid</var>
and <var>gid</var>.
Availability: Unix.
</dl>

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

<P>
<dl><dt><b><a name='l2h-955'><tt class='function'>listdir</tt></a></b> (<var>path</var>)
<dd>
Return a list containing the names of the entries in the directory.
The list is in arbitrary order.  It does not include the special
entries <code>'.'</code> and <code>'..'</code> even if they are present in the
directory.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-956'><tt class='function'>lstat</tt></a></b> (<var>path</var>)
<dd>
Like <tt class="function">stat()</tt>, but do not follow symbolic links.
Availability: Unix.
</dl>

<P>
<dl><dt><b><a name='l2h-957'><tt class='function'>mkfifo</tt></a></b> (<var>path</var><big>[</big><var>, mode</var><big>]</big>)
<dd>
Create a FIFO (a named pipe) named <var>path</var> with numeric mode
<var>mode</var>.  The default <var>mode</var> is <code>0666</code> (octal).  The current
umask value is first masked out from the mode.
Availability: Unix.

<P>
FIFOs are pipes that can be accessed like regular files.  FIFOs exist
until they are deleted (for example with <tt class="function">os.unlink()</tt>).
Generally, FIFOs are used as rendezvous between ``client'' and
``server'' type processes: the server opens the FIFO for reading, and
the client opens it for writing.  Note that <tt class="function">mkfifo()</tt>
doesn't open the FIFO -- it just creates the rendezvous point.
</dl>

<P>
<dl><dt><b><a name='l2h-958'><tt class='function'>mkdir</tt></a></b> (<var>path</var><big>[</big><var>, mode</var><big>]</big>)
<dd>
Create a directory named <var>path</var> with numeric mode <var>mode</var>.
The default <var>mode</var> is <code>0777</code> (octal).  On some systems,
<var>mode</var> is ignored.  Where it is used, the current umask value is
first masked out.
Availability: Macintosh, Unix, Windows.
</dl>

<P>
<dl><dt><b><a name='l2h-959'><tt class='function'>makedirs</tt></a></b> (<var>path</var><big>[</big><var>, mode</var><big>]</big>)
<dd>

Recursive directory creation function.  Like <tt class="function">mkdir()</tt>,
but makes all intermediate-level directories needed to contain the
leaf directory.  Throws an <tt class="exception">error</tt> exception if the leaf
directory already exists or cannot be created.  The default <var>mode</var>
is <code>0777</code> (octal).

New in version 1.5.2.

</dl>

<P>
<dl><dt><b><a name='l2h-960'><tt class='function'>pathconf</tt></a></b> (<var>path, name</var>)
<dd>
Return system configuration information relevant to a named file.
<var>name</var> specifies the configuration value to retrieve; it may be a
string which is the name of a defined system value; these names are
specified in a number of standards (POSIX.1, Unix95, Unix98, and
others).  Some platforms define additional names as well.  The names
known to the host operating system are given in the
<code>pathconf_names</code> dictionary.  For configuration variables not
included in that mapping, passing an integer for <var>name</var> is also
accepted.
Availability: Unix.

<P>
If <var>name</var> is a string and is not known, <tt class="exception">ValueError</tt> is
raised.  If a specific value for <var>name</var> is not supported by the
host system, even if it is included in <code>pathconf_names</code>, an
<tt class="exception">OSError</tt> is raised with <tt class="constant">errno.EINVAL</tt> for the
error number.
</dl>

<P>
<dl><dt><b><a name='l2h-961'><tt>pathconf_names</tt></a></b>
<dd>
Dictionary mapping names accepted by <tt class="function">pathconf()</tt> and
<tt class="function">fpathconf()</tt> to the integer values defined for those names
by the host operating system.  This can be used to determine the set
of names known to the system.
Availability: Unix.
</dl>

⌨️ 快捷键说明

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