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语句,您的代码将按预期工作。不工作是什么意思?有我们能看到的堆栈跟踪吗?