Site icon Machine Learning Projects

Python Program to Check the File Size – 2023

Machine Learning Projects

Hey guys, in this blog we will see a Python Program to Check the File Size.

Example 1: Using the os module

import os

file_stat = os.stat('img1.jpg')
print(file_stat.st_size)

Output

793103

Example 2: Using the pathlib module

from pathlib import Path

file = Path('img1.jpg')
print(file.stat().st_size)

Output

793103

Check out our other python programming examples

Exit mobile version