Search code examples
pythonfilefile-length

How to check whether a file is empty or not


I have a text file. How can I check whether it's empty or not?


Solution

  • >>> import os
    >>> os.stat("file").st_size == 0
    True