Python 检测空文件

import os
if os.path.getsize(file_path)==0:
    print("%s is a empty file"%(file_path))
import os
if os.stat(file_path).st_size == 0:
    print("%s is a empty file"%(file_path))

参考:
https://cloud.tencent.com/developer/ask/31818

你可能感兴趣的:(Python 检测空文件)