-3
我需要代码,这是能够在同一目录中,如果它包含任何文件夹或文件 的python脚本来检查文件夹从How to check to see if a folder contains files using python 3这个代码不起作用检查的文件夹,如果它包含任何python3
import os
for dirpath, dirnames, files in os.walk('.'):
if files:
print dirpath, 'Contains files or folders'
if not files:
print dirpath, 'Contains nothing'
我正在检查该文件夹是DeviceTest
这是否检查当前目录或做我必须要改变的目录检查吗? – JJLongOne
转到根,它会检查它是否为空,如果你想检查给定文件夹中的所有文件夹,你可以遍历整个目录 –
你可以编辑你的代码让它检查当前目录下的DeviceTest – JJLongOne