Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python os.walk不在子目录中保存图像_Python_Python 3.x_Python Imaging Library_Os.walk - Fatal编程技术网

Python os.walk不在子目录中保存图像

Python os.walk不在子目录中保存图像,python,python-3.x,python-imaging-library,os.walk,Python,Python 3.x,Python Imaging Library,Os.walk,Images是一个包含10个子文件夹的文件夹,每个子文件夹都有一个我正在调整大小并保存在同一位置的图像,但是os.walk不起作用。有人能检查我做错了什么吗 path='E:/Dataset_Final/Images/' def count_em(path): for root, dirs, files in sorted(os.walk(path)): for file_ in files: full_file_path = os.path.jo

Images
是一个包含10个子文件夹的文件夹,每个子文件夹都有一个我正在调整大小并保存在同一位置的图像,但是
os.walk
不起作用。有人能检查我做错了什么吗

path='E:/Dataset_Final/Images/'
def count_em(path):
    for root, dirs, files in sorted(os.walk(path)):
        for file_ in files:
            full_file_path = os.path.join(root, file_)
            print (full_file_path)
            img = Image.open(full_file_path)
            new_width  = 32
            new_height = 32
            img = img.resize((new_width, new_height), Image.ANTIALIAS)
            img.save(os.path.join(root, file_+''),'png')
        return 
count_em(path)

在第一个目录之后返回


删除return语句,您的代码将按预期工作。

不工作是什么意思?有我们能看到的堆栈跟踪吗?