os-procinfo.html
来自「一本很好的python的说明书,适合对python感兴趣的人」· HTML 代码 · 共 298 行
HTML
298 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>6.1.1 Process Parameters </title>
<META NAME="description" CONTENT="6.1.1 Process Parameters ">
<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-newstreams.html" tppabs="http://www.python.org/doc/current/lib/os-newstreams.html">
<LINK REL="previous" href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">
<LINK REL="up" href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">
<LINK REL="next" href="os-newstreams.html" tppabs="http://www.python.org/doc/current/lib/os-newstreams.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.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-newstreams.html" tppabs="http://www.python.org/doc/current/lib/os-newstreams.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="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">6.1 os </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-newstreams.html" tppabs="http://www.python.org/doc/current/lib/os-newstreams.html">6.1.2 File Object Creation</A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H2>
<BR>
6.1.1 Process Parameters
</H2>
<P>
These functions and data items provide information and operate on the
current process and user.
<P>
<dl><dt><b><a name='l2h-870'><tt>environ</tt></a></b>
<dd>
A mapping object representing the string environment. For example,
<code>environ['HOME']</code> is the pathname of your home directory (on some
platforms), and is equivalent to <code>getenv("HOME")</code> in C.
<P>
If the platform supports the <tt class="function">putenv()</tt> function, this
mapping may be used to modify the environment as well as query the
environment. <tt class="function">putenv()</tt> will be called automatically when
the mapping is modified.
<P>
If <tt class="function">putenv()</tt> is not provided, this mapping may be passed to
the appropriate process-creation functions to cause child processes to
use a modified environment.
</dl>
<P>
<dl><dt><b><tt class='function'>chdir</tt></b> (<var>path</var>)
<dd>
<dt><b><tt class='function'>getcwd</tt></b> ()
<dd>
These functions are described in ``Files and Directories'' (section
<A href="os-file-dir.html#os-file-dir" tppabs="http://www.python.org/doc/current/lib/os-file-dir.html#os-file-dir">6.1.4</A>).
</dl>
<P>
<dl><dt><b><a name='l2h-871'><tt class='function'>ctermid</tt></a></b> ()
<dd>
Return the filename corresponding to the controlling terminal of the
process.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-872'><tt class='function'>getegid</tt></a></b> ()
<dd>
Return the current process' effective group id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-873'><tt class='function'>geteuid</tt></a></b> ()
<dd>
Return the current process' effective user id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-874'><tt class='function'>getgid</tt></a></b> ()
<dd>
Return the current process' group id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-875'><tt class='function'>getgroups</tt></a></b> ()
<dd>
Return list of supplemental group ids associated with the current
process.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-876'><tt class='function'>getlogin</tt></a></b> ()
<dd>
Return the actual login name for the current process, even if there
are multiple login names which map to the same user id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-877'><tt class='function'>getpgrp</tt></a></b> ()
<dd>
Return the current process group id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-878'><tt class='function'>getpid</tt></a></b> ()
<dd>
Return the current process id.
Availability: Unix, Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-879'><tt class='function'>getppid</tt></a></b> ()
<dd>
Return the parent's process id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-880'><tt class='function'>getuid</tt></a></b> ()
<dd>
Return the current process' user id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-881'><tt class='function'>putenv</tt></a></b> (<var>varname, value</var>)
<dd>
Set the environment variable named <var>varname</var> to the string
<var>value</var>. Such changes to the environment affect subprocesses
started with <tt class="function">os.system()</tt>, <tt class="function">popen()</tt> or
<tt class="function">fork()</tt> and <tt class="function">execv()</tt>.
Availability: most flavors of Unix, Windows.
<P>
When <tt class="function">putenv()</tt> is
supported, assignments to items in <code>os.environ</code> are automatically
translated into corresponding calls to <tt class="function">putenv()</tt>; however,
calls to <tt class="function">putenv()</tt> don't update <code>os.environ</code>, so it is
actually preferable to assign to items of <code>os.environ</code>.
</dl>
<P>
<dl><dt><b><a name='l2h-882'><tt class='function'>setegid</tt></a></b> (<var>egid</var>)
<dd>
Set the current process's effective group id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-883'><tt class='function'>seteuid</tt></a></b> (<var>euid</var>)
<dd>
Set the current process's effective user id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-884'><tt class='function'>setgid</tt></a></b> (<var>gid</var>)
<dd>
Set the current process' group id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-885'><tt class='function'>setpgrp</tt></a></b> ()
<dd>
Calls the system call <tt class="cfunction">setpgrp()</tt> or <tt class="cfunction">setpgrp(0,
0)</tt> depending on which version is implemented (if any). See the
Unix manual for the semantics.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-886'><tt class='function'>setpgid</tt></a></b> (<var>pid, pgrp</var>)
<dd>
Calls the system call <tt class="cfunction">setpgid()</tt>. See the Unix manual
for the semantics.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-887'><tt class='function'>setreuid</tt></a></b> (<var>ruid, euid</var>)
<dd>
Set the current process's real and effective user ids.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-888'><tt class='function'>setregid</tt></a></b> (<var>rgid, egid</var>)
<dd>
Set the current process's real and effective group ids.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-889'><tt class='function'>setsid</tt></a></b> ()
<dd>
Calls the system call <tt class="cfunction">setsid()</tt>. See the Unix manual
for the semantics.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-890'><tt class='function'>setuid</tt></a></b> (<var>uid</var>)
<dd>
Set the current process' user id.
Availability: Unix.
</dl>
<P>
<dl><dt><b><a name='l2h-891'><tt class='function'>strerror</tt></a></b> (<var>code</var>)
<dd>
Return the error message corresponding to the error code in
<var>code</var>.
Availability: Unix, Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-892'><tt class='function'>umask</tt></a></b> (<var>mask</var>)
<dd>
Set the current numeric umask and returns the previous umask.
Availability: Unix, Windows.
</dl>
<P>
<dl><dt><b><a name='l2h-893'><tt class='function'>uname</tt></a></b> ()
<dd>
Return a 5-tuple containing information identifying the current
operating system. The tuple contains 5 strings:
<code>(<var>sysname</var>, <var>nodename</var>, <var>release</var>, <var>version</var>,
<var>machine</var>)</code>. Some systems truncate the nodename to 8
characters or to the leading component; a better way to get the
hostname is <tt class="function">socket.gethostname()</tt>
or even
<code>socket.gethostbyaddr(socket.gethostname())</code>.
Availability: recent flavors of Unix.
</dl>
<P>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.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-newstreams.html" tppabs="http://www.python.org/doc/current/lib/os-newstreams.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="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">6.1 os </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-newstreams.html" tppabs="http://www.python.org/doc/current/lib/os-newstreams.html">6.1.2 File Object Creation</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 + =
减小字号Ctrl + -
显示快捷键?