Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I have a text file.

How can I check whether it's empty or not?

1 Answer

0 votes
by (106k points)
You can use the below-mentioned code to check whether a file is empty or not:-

>>> import os 

>>> os.stat("file").st_size == 0 

True

     

 

Related questions

0 votes
2 answers
+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...