Модуль ОС в Python предоставляет функции для взаимодействия с операционной системой. ОС поставляется под стандартные служебные модули Python. Этот модуль предоставляет портативный способ использования функциональных возможностей, зависящих от операционной системы.
os.stat()
в Python выполняет системный вызов stat () по указанному пути. Этот метод используется для получения статуса указанного пути.
Syntax: os.stat(path)
Parameter:
path: A string or bytes object representing a valid pathReturn Type: This method returns a ‘stat_result’ object of class ‘os.stat_result’ which represents the status of specified path. The returned ‘stat-result’ object has following attributes:
- st_mode: It represents file type and file mode bits (permissions).
- st_ino: It represents the inode number on Unix and the file index on Windows platform.
- st_dev: It represents the identifier of the device on which this file resides.
- st_nlink: It represents the number of hard links.
- st_uid: It represents the user identifier of the file owner.
- st_gid: It represents the group identifier of the file owner.
- st_size: It represents the size of the file in bytes.
- st_atime: It represents the time of most recent access. It is expressed in seconds.
- st_mtime: It represents the time of most recent content modification. It is expressed in seconds.
- st_ctime: It represents the time of most recent metadata change on Unix and creation time on Windows. It is expressed in seconds.
- st_atime_ns: It is same as st_atime but the time is expressed in nanoseconds as an integer.
- st_mtime_ns: It is same as st_mtime but the time is expressed in nanoseconds as an integer.
- st_ctime_ns: It is same as st_ctime but the time is expressed in nanoseconds as an integer.
- st_blocks: It represents the number of 512-byte blocks allocated for file.
- st_rdev: It represents the type of device, if an inode device.
- st_flags: It represents the user defined flags for file.
Note: Some attributes are platform dependent and are subject to availability.
Код: использование метода os.stat ()
|
Выход:
os.stat_result(st_mode=33188, st_ino=795581, st_dev=2056, st_nlink=1, st_uid=1000, st_gid=1000, st_size=243, st_atime=1531567080, st_mtime=1530346690, st_ctime=1530346690)
Рекомендуемые посты:
- метод класса против статического метода в Python
- Python | метод next ()
- Python | метод os.dup ()
- Python | метод set ()
- Python | метод os.sched_rr_get_interval ()
- Python | метод os.sched_get_priority_max ()
- Python | метод cmath.log ()
- Python PIL | Kernel () метод
- Python | метод os.get_terminal_size ()
- Python | метод cmath.exp ()
- Python | метод os.sched_get_priority_min ()
- Python | sympy.Pow () метод
- Python | sympy.Mod () метод
- Python PIL | Метод RankFilter ()
- Python | sympy.csc () метод
0.00 (0%) 0 votes