grp
— The group database¶
This module provides access to the Unix group database. 此模块提供对Unix组数据库的访问。It is available on all Unix versions.它在所有Unix版本上都可用。
Group database entries are reported as a tuple-like object, whose attributes correspond to the members of the 组数据库条目报告为一个类似元组的对象,其属性对应于group
structure (Attribute field below, see <grp.h>
):group
结构的成员(下面的属性字段,请参阅<grph>
):
Index |
Attribute |
Meaning |
---|---|---|
0 |
gr_name |
|
1 |
gr_passwd |
|
2 |
gr_gid |
|
3 |
gr_mem |
|
The gid is an integer, name and password are strings, and the member list is a list of strings. gid是一个整数,名称和密码是字符串,成员列表是字符串列表。(Note that most users are not explicitly listed as members of the group they are in according to the password database. (请注意,根据密码数据库,大多数用户并没有明确列为所属组的成员。Check both databases to get complete membership information. 请检查这两个数据库以获取完整的成员信息。Also note that a 另请注意,以gr_name
that starts with a +
or -
is likely to be a YP/NIS reference and may not be accessible via getgrnam()
or getgrgid()
.)+
或-
开头的gr_name
可能是YP/NIS引用,可能无法通过getgrnam()
或getgrgid()
访问。)
It defines the following items:它定义了以下项目:
-
grp.
getgrgid
(gid)¶ Return the group database entry for the given numeric group ID.返回给定数字组ID的组数据库条目。如果找不到所要求的条目,则会引发KeyError
is raised if the entry asked for cannot be found.KeyError
。Deprecated since version 3.6:自3.6版起弃用:Since Python 3.6 the support of non-integer arguments like floats or strings in自Python 3.6以来,不赞成在getgrgid()
is deprecated.getgrgid()
中支持浮点或字符串等非整数参数。
-
grp.
getgrnam
(name)¶ Return the group database entry for the given group name.返回给定组名称的组数据库条目。如果找不到要求的条目,则会引发KeyError
is raised if the entry asked for cannot be found.KeyError
。
-
grp.
getgrall
()¶ Return a list of all available group entries, in arbitrary order.按任意顺序返回所有可用组条目的列表。