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

📄 module-pwd.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>8.2 pwd -- The password database</title>
<META NAME="description" CONTENT="8.2 pwd -- The password database">
<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="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.html">
<LINK REL="previous" href="module-posix.html" tppabs="http://www.python.org/doc/current/lib/module-posix.html">
<LINK REL="up" href="unix.html" tppabs="http://www.python.org/doc/current/lib/unix.html">
<LINK REL="next" href="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="posix-contents.html" tppabs="http://www.python.org/doc/current/lib/posix-contents.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="unix.html" tppabs="http://www.python.org/doc/current/lib/unix.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="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.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="posix-contents.html" tppabs="http://www.python.org/doc/current/lib/posix-contents.html">8.1.2 Module Contents</A>
<b class="navlabel">Up:</b> <a class="sectref" href="unix.html" tppabs="http://www.python.org/doc/current/lib/unix.html">8. Unix Specific Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.html">8.3 grp  </A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0010200000000000000000">
8.2 <tt class="module">pwd</tt> --
         The password database</A>
</H1>

<P>
  
<p class='availability'>Availability: <span
 class='platform'>Unix</span>.</p>

<P>
This module provides access to the Unix user account and password
database.  It is available on all Unix versions.

<P>
Password database entries are reported as 7-tuples containing the
following items from the password database (see <code>&lt;pwd.h&gt;</code>), in order:

<P>
<table border align="center" style="border-collapse: collapse">
  <thead>
    <tr>
      <th align="right"><b>Index</b>&nbsp;</th>
      <th align="left"><b>Field</b>&nbsp;</th>
      <th align="left"><b>Meaning</b>&nbsp;</th>
    </thead>
  <tbody valign='baseline'>
    <tr><td align="right" valign="baseline">0&nbsp;</td>
        <td align="left"><code>pw_name</code></td>
        <td align="left">Login name</td>
    <tr><td align="right" valign="baseline">1&nbsp;</td>
        <td align="left"><code>pw_passwd</code></td>
        <td align="left">Optional encrypted password</td>
    <tr><td align="right" valign="baseline">2&nbsp;</td>
        <td align="left"><code>pw_uid</code></td>
        <td align="left">Numerical user ID</td>
    <tr><td align="right" valign="baseline">3&nbsp;</td>
        <td align="left"><code>pw_gid</code></td>
        <td align="left">Numerical group ID</td>
    <tr><td align="right" valign="baseline">4&nbsp;</td>
        <td align="left"><code>pw_gecos</code></td>
        <td align="left">User name or comment field</td>
    <tr><td align="right" valign="baseline">5&nbsp;</td>
        <td align="left"><code>pw_dir</code></td>
        <td align="left">User home directory</td>
    <tr><td align="right" valign="baseline">6&nbsp;</td>
        <td align="left"><code>pw_shell</code></td>
        <td align="left">User command interpreter</td></tbody>
</table>

<P>
The uid and gid items are integers, all others are strings.
<tt class="exception">KeyError</tt> is raised if the entry asked for cannot be found.

<P>
<b>Note:</b> In traditional Unix the field <code>pw_passwd</code> usually
contains a password encrypted with a DES derived algorithm (see module
<tt class='module'><a href="module-crypt.html" tppabs="http://www.python.org/doc/current/lib/module-crypt.html">crypt</a></tt>).  However most modern unices 
use a so-called <i>shadow password</i> system.  On those unices the
field <code>pw_passwd</code> only contains a asterisk (<code>'*'</code>) or the 
letter "<tt class="character">x</tt>" where the encrypted password is stored in a file
<span class="file">/etc/shadow</span> which is not world readable.

<P>
It defines the following items:

<P>
<dl><dt><b><a name='l2h-1816'><tt class='function'>getpwuid</tt></a></b> (<var>uid</var>)
<dd>
Return the password database entry for the given numeric user ID.
</dl>

<P>
<dl><dt><b><a name='l2h-1817'><tt class='function'>getpwnam</tt></a></b> (<var>name</var>)
<dd>
Return the password database entry for the given user name.
</dl>

<P>
<dl><dt><b><a name='l2h-1818'><tt class='function'>getpwall</tt></a></b> ()
<dd>
Return a list of all available password database entries, in arbitrary order.
</dl>

<P>
<div class='seealso'>
  <p class='heading'><b>See Also:</b></p>

  <dl compact class="seemodule">
    <dt>Module <b><tt class='module'><a href="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.html">grp</a></tt>:</b>
    <dd>An interface to the group database, similar to this.
  </dl>
</div>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="posix-contents.html" tppabs="http://www.python.org/doc/current/lib/posix-contents.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="unix.html" tppabs="http://www.python.org/doc/current/lib/unix.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="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.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="posix-contents.html" tppabs="http://www.python.org/doc/current/lib/posix-contents.html">8.1.2 Module Contents</A>
<b class="navlabel">Up:</b> <a class="sectref" href="unix.html" tppabs="http://www.python.org/doc/current/lib/unix.html">8. Unix Specific Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-grp.html" tppabs="http://www.python.org/doc/current/lib/module-grp.html">8.3 grp  </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 + -