Python os.stat() Method with example

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

Syntax

The following below is the syntax for Python Os stat() method -

Parameter Details

  • path — This is the file path whose stat information is needed.

Return Value

This returns information about a file.

Example

The following below is a simple example -

Output

When the above code is executed, it will produce the following result -

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.

A tutorial blog that provides tutorials on Web Design, Programming, Java Technologies, Mobile App Development, Database, Machine Learning, etc.