上一话题

posix — 最常见的 POSIX 系统调用

下一话题
就业培训     下载中心     Wiki     联络
登录   注册

Log
  1. 首页
  2. Python 3.12.4
  3. 索引
  4. 模块
  5. 下一
  6. 上一
  7. Python 标准库
  8. Unix 特定服务
  9. pwd — 口令数据库

pwd — 口令数据库 ¶


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

可用性 :Unix,非 Emscripten,非 WASI。

Password database entries are reported as a tuple-like object, whose attributes correspond to the members of the passwd structure (Attribute field below, see <pwd.h> ):

索引

属性

含义

0

pw_name

Login name
1

pw_passwd

Optional encrypted password
2

pw_uid

Numerical user ID
3

pw_gid

Numerical group ID
4

pw_gecos

User name or comment field
5

pw_dir

User home directory
6

pw_shell

User command interpreter

The uid and gid items are integers, all others are strings. KeyError is raised if the entry asked for cannot be found.

注意

In traditional Unix the field pw_passwd usually contains a password encrypted with a DES derived algorithm (see module crypt ). However most modern unices use a so-called shadow password system. On those unices the pw_passwd field only contains an asterisk ( '*' ) or the letter 'x' where the encrypted password is stored in a file /etc/shadow which is not world readable. Whether the pw_passwd field contains anything useful is system-dependent. If available, the spwd module should be used where access to the encrypted password is required.

It defines the following items:

pwd. getpwuid ( uid ) ¶

Return the password database entry for the given numeric user ID.

pwd. getpwnam ( name ) ¶

Return the password database entry for the given user name.

pwd. getpwall ( ) ¶

Return a list of all available password database entries, in arbitrary order.

另请参阅

模块 grp

An interface to the group database, similar to this.

模块 spwd

An interface to the shadow password database, similar to this.

上一话题

posix — 最常见的 POSIX 系统调用

下一话题

grp — 组数据库

本页

  • 报告 Bug
  • 展示源

快速搜索

键入搜索术语或模块、类、函数名称。

  1. 首页
  2. Python 3.12.4
  3. 索引
  4. 模块
  5. 下一
  6. 上一
  7. Python 标准库
  8. Unix 特定服务
  9. pwd — 口令数据库

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1