Python方法stat()在给定路径上执行stat系统调用。
os.stat(path)
path - 这是需要其统计信息的路径。
以下是STAT Structure-的成员列表
链接:https://www.learnfk.comhttps://www.learnfk.com/python/os-stat.html
来源:LearnFk无涯教程网
st_mode - 保护位。
st_ino - 信息节点编号。
st_dev - 设备。
st_nlink - 硬链接数量。
st_uid - 所有者的用户ID。
st_gid - 所有者的组ID。
st_size - 文件的大小,以字节为单位。
st_atime - 最近访问的-时间。
st_mtime - 最近内容修改的时间。
st_ctime - 最近元数据更改的时间。
以下示例显示stat()方法的用法。
# !/usr/bin/python import os, sys # 显示文件“a2.py”的统计信息 statinfo=os.stat('a2.py') print statinfo
当无涯教程运行上面的程序时,它产生以下输出-
posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L, st _nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=13 30498089, st_ctime=1330498089)
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)