grp --- 組數(shù)據(jù)庫?


該模塊提供對Unix組數(shù)據(jù)庫的訪問。 它在所有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>):

索引

屬性

含意

0

gr_name

組名

1

gr_passwd

(加密的)組密碼; 通常為空

2

gr_gid

數(shù)字組ID

3

gr_mem

組內(nèi)所有成員的用戶名

gid 是整數(shù),名稱和密碼是字符串,成員列表是字符串列表。 (注意,大多數(shù)用戶未根據(jù)密碼數(shù)據(jù)庫顯式列為所屬組的成員。請檢查兩個數(shù)據(jù)庫以獲取完整的成員資格信息。還要注意,以 +- 開頭的 gr_name 可能是 YP/NIS 引用,可能無法通過 getgrnam()getgrgid() 訪問。)

本模塊定義如下內(nèi)容:

grp.getgrgid(gid)?

返回給定數(shù)字組 ID 的組數(shù)據(jù)庫條目。 如果請求的條目無法找到則會引發(fā) KeyError。

3.6 版后已移除: 從 Python 3.6 開始,棄用對 getgrgid() 中的 float 或 string 等非 integer 參數(shù)的支持。

grp.getgrnam(name)?

返回給定組名的組數(shù)據(jù)庫條目。 如果找不到要求的條目,則會引發(fā) KeyError 錯誤。

grp.getgrall()?

以任意順序返回所有可用組條目的列表。

參見

模塊 pwd

用戶數(shù)據(jù)庫的接口,與此類似。

模塊 spwd

針對影子密碼數(shù)據(jù)庫的接口,與本模塊類似。