小白教程
所有教程
关于
Search
172.70.178.98
172.70.178.98
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 os stat”的源代码
本页内容
上一节:
Python3_os_rmdir
下一节:
Python3_os_stat_float_times
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:os.stat(path)}}[[Category:python3 os file methods|50]] = Python3 os.stat() 方法 = [[python3 os file methods|Python3 OS 文件/目录方法]] === 概述 === os.stat() 方法用于在给定的路径上执行一个系统 stat 的调用。 === 语法 === '''stat()'''方法语法格式如下: <sample title="" desc="" lang="python" hererun="1"> os.stat(path) </sample> === 参数 === * '''path''' -- 指定路径 === 返回值 === stat 结构: * '''st_mode:''' inode 保护模式 * '''st_ino:''' inode 节点号。 * '''st_dev:''' inode 驻留的设备。 * '''st_nlink:''' inode 的链接数。 * '''st_uid:''' 所有者的用户ID。 * '''st_gid:''' 所有者的组ID。 * '''st_size:''' 普通文件以字节为单位的大小;包含等待某些特殊文件的数据。 * '''st_atime:''' 上次访问的时间。 * '''st_mtime:''' 最后一次修改的时间。 * '''st_ctime:''' 由操作系统报告的"ctime"。在某些系统上(如Unix)是最新的元数据更改的时间,在其它系统上(如Windows)是创建时间(详细信息参见平台的文档)。 == 以下实例演示了 stat() 方法的使用: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 import os, sys # 显示文件 "a2.py" 信息 statinfo = os.stat('a2.py') print (statinfo) </sample> 执行以上程序输出结果为: <sample title="" desc="" lang="python" hererun="1"> 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) </sample> [[python3 os file methods|Python3 OS 文件/目录方法]]
返回至“
Python3 os stat
”。
上一节:
Python3_os_rmdir
下一节:
Python3_os_stat_float_times