{"id":10541,"date":"2021-12-29T15:28:57","date_gmt":"2021-12-29T09:58:57","guid":{"rendered":"https:\/\/pynative.com\/?p=10541"},"modified":"2021-12-29T15:31:54","modified_gmt":"2021-12-29T10:01:54","slug":"python-get-file-size","status":"publish","type":"post","link":"https:\/\/pynative.com\/python-get-file-size\/","title":{"rendered":"Python Check File Size"},"content":{"rendered":"\n

In this tutorial, you\u2019ll learn how to get file size in Python.<\/p>\n\n\n\n

Whenever we work with files, sometimes we need to check file size before performing any operation. For example, if you are trying to copy content from one file into another file. In this case, we can check if the file size is greater than 0 before performing the file copying operation.<\/p>\n\n\n\n

In this article, We will use the following three methods<\/strong> of an OS and pathlib module to get file size.<\/p>\n\n\n\n

os.path module<\/strong>:<\/p>\n\n\n\n