Last updated 3 years ago
Was this helpful?
In this example, you will learn to check the file size.
To understand this example, you should have the knowledge of the following topics:
import os file_stat = os.stat('my_file.txt') print(file_stat.st_size)
Output
34
The unit of the file size is byte.
byte
from pathlib import Path file = Path('my_file.txt') print(file.stat().st_size)