- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
Interpreting stat() results using Python
The stat() method is part of OS module which describes various OS related operations on files and directories. For example, if we want to know various user defined flags for a file or size of the file in bytes.
Functions in os.stat() module
Below is a list of some sample functions available in stat() and their meaning.
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_ctime − It represents the time of most recent metadata change on Unix and creation time on Windows. It is expressed in seconds.
st_blocks − It represents the number of 512-byte blocks allocated for file.
st_uid − It represents the user identifier of the file owner.
st_gid − It represents the group identifier of the file owner.
st_dev − It represents the identifier of the device on which this file resides.
st_flags − It represents the user defined flags for file.
In the below program we will see how some of the above functions are used.
import os # Choose a file path = 'E:\customers.csv' # Get the status status = os.stat(path) # Print the result print(status)
Running the above code gives us the following result −
os.stat_result(st_mode=33206, st_ino=1125899906970419, st_dev=1614938858, st_nlink=1, st_uid=0, st_gid=0, st_size=261693, st_atime=1593271710, st_mtime=1593271710, st_ctime=1593271710)
- Related Articles
- How to get stat of a file using Python?
- stat() function in PHP
- What is the meaning of interpreting?
- How can Tensorflow be used to visualize training results using Python?
- How can Tensorflow be used to plot the results using Python?
- How to Visualize API results with Python
- Get all results using WHERE clause in MySQL?
- How to plot 2d FEM results using matplotlib?
- Learn How to Use http stat to Find out Website’s Performance
- Program to find Fibonacci series results up to nth term in Python
- Urinalysis: Purposes, Types, Results
- Get a fixed number of results in descending order using a MySQL query
- Order MySQL results without identifier?