How to check whether a file is empty or not

To check if a file is empty in Python, you can use the os.path.getsize() function, which returns the size of the file in bytes. If the size is 0, the file is empty.