In this article, we'll know how to get file size in python using the os module

syntax:


os.path.getsize(path)

example:


import os    
try : 
    os.path.getsize('/xx/xx/xx/xx/xx/img/access_bg.jpg')
#if the file does not exist or is inaccessible we'll get err
except OSError : 
    print("Path does not exists or is inaccessible")


output:

180200 #bytes

Return the size, in bytes,

English today is not an art to be mastered it's just a tool to use to get a result