更新时间:2023-09-25 22:11:16
'files' 已经告诉你目录中的内容.只需检查一下:
'files' already tells you whats in the directory. Just check it:
for dirpath, dirnames, files in os.walk('.'):
if files:
print(dirpath, 'has files')
if not files:
print(dirpath, 'is empty')