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)

  

posted @ 2022-09-19 20:54  lucky_tomato  阅读(721)  评论(0编辑  收藏  举报