Python获取文件所属用户和组名
stat_info = os.stat('host.txt') uid = stat_info.st_uid gid = stat_info.st_gid user = pwd.getpwuid(uid)[0] group = grp.getgrgid(gid)[0] print(user,group)
stat_info = os.stat('host.txt') uid = stat_info.st_uid gid = stat_info.st_gid user = pwd.getpwuid(uid)[0] group = grp.getgrgid(gid)[0] print(user,group)