python怎么判断一个文件为空?
获取文件大小,如果文件大小等于0就是空的,如下:
import os size = os.path.getsize('d:/abc.txt') if size == 0: print('文件是空的') else: print('文件不是空的')
相关