Answers for "check file is empty or not in python"

4

python check if a file is empty

import os
if os.stat("yourfile.extension").st_size == 0:
#note: file has to be in same directory as python script#
  print('empty')
Posted by: Guest on August-09-2020
1

python check if file has content

>>> import os
>>> os.stat("file").st_size == 0
True
Posted by: Guest on March-26-2020
0

how to check if a file is empty using python

>>> import os
>>> os.stat("file").st_size == 0
True
Posted by: Guest on June-21-2021

Code answers related to "check file is empty or not in python"

Python Answers by Framework

Browse Popular Code Answers by Language