Hello dear readers! Welcome back to another section of my tutorial on Python. In this tutorial guide, we are going to be studying about the Os stat() method.
The Python os stat() method performs a stat system call on the given path.
Below is the list of members of stat structure -
- st_dev — ID of the device containing file.
- st_ino — inode number
- st_mode — protection
- st_nlink — the number of hard links
- st_uid — user ID of owner
- st_gid — group ID of owner
- st_size — total size, in bytes
- st_atime — the time of last access
- st_mtime — the time of last modification
- st_ctime — time of the most recent metadata change
The following below is the syntax for Python Os stat() method -
os.stat( path )
- path — This is the file path whose stat information is needed.
This returns information about a file.
The following below is a simple example -
import os, sys
# showing stat information of file "a2.py"
statinfo = os.stat('a2.py')
When the above code is executed, it will produce the following result -
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)
Alright guys! This is where we are rounding up for this tutorial post. In my next tutorial, we are going to be studying about the Python OS stat_float_times() Method.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Originally published at https://www.webdesigntutorialz.com.