pwd — The password database - Python 3.12.0a3 documentation 编辑
This module provides access to the Unix user account and password database. It is available on all Unix versions.
Availability: not Emscripten, not WASI.
This module does not work or is not available on WebAssembly platforms wasm32-emscripten
and wasm32-wasi
. See WebAssembly platforms for more information.
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>
):
Index | Attribute | Meaning |
---|---|---|
0 |
| Login name |
1 |
| Optional encrypted password |
2 |
| Numerical user ID |
3 |
| Numerical group ID |
4 |
| User name or comment field |
5 |
| User home directory |
6 |
| 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.
Note
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.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论