Python os.stat () method
Python OS file / directory methods
Outline
os.stat () method for executing a system call stat on a given path.
grammar
stat () method syntax is as follows:
os.stat(path)
parameter
path - the path specified
return value
stat structure:
- st_mode: inode protection mode
- st_ino: inode node number.
- st_dev: inode resides equipment.
- st_nlink: inode number of links.
- st_uid: user ID owner.
- st_gid: owner's group ID.
- st_size: regular file in bytes the size of the units; wait contains some special data files.
- st_atime: the last access time.
- st_mtime: last modified.
- st_ctime: report by the operating system's "ctime".On some systems (such as Unix) is the time of most recent metadata changes in the other systems (such as Windows) is the creation time (see platform documentation for details).
Examples
The following example demonstrates the stat () method of use:
#!/usr/bin/python # -*- coding: UTF-8 -*- import os, sys # 显示文件 "a2.py" 信息 statinfo = os.stat('a2.py') print statinfo
The above program output is:
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)