python中打开的文件太多
我正在尝试调整图像的大小。它工作正常,但my(即python中打开的文件太多,python,django,python-imaging-library,Python,Django,Python Imaging Library,我正在尝试调整图像的大小。它工作正常,但my(即至_字段)正在打开但未关闭。因此,我有一个错误打开的文件太多。我尝试了一些解决方案,但没能解决问题。代码如下: if( to_field.width != size[0] and to_field.height != size[1] ): to_field.open() image = Image.open(StringIO(to_field.read())) old_file_path = to_field.path im
至_字段
)正在打开但未关闭。因此,我有一个错误打开的文件太多
。我尝试了一些解决方案,但没能解决问题。代码如下:
if( to_field.width != size[0] and to_field.height != size[1] ):
to_field.open()
image = Image.open(StringIO(to_field.read()))
old_file_path = to_field.path
image.resize(size).save(to_field.path)
有什么建议吗?老问题,但我认为django字段到_字段需要关闭:
to_field.close()
您是否/应该
image.close()
?(不熟悉PIL…)是的,我试过了。没有属性“close”可能与的重复