/ indexsendjepp的ValueError:关闭文件的I / O操作

时间:2017-02-21 07:37:59

标签: python django python-3.x file zipfile

我想在&f; comic \ picture \ jepp'上传zip文件。我使用这段代码:

def sendjepp(request):
    docuPath ='F:comic\picture\jepp'
    temp = tempfile.TemporaryFile()
    f = zipfile.ZipFile(temp, 'w', zipfile.ZIP_DEFLATED)
    for dirpath,dirnames,filenames in os.walk(docuPath):
          for filename in filenames:
              f.write(os.path.join(dirpath,filename))
    # f.close()
    wrapper = FileWrapper(temp)
    response = HttpResponse(wrapper, content_type='application/zip')
    response['Content-Disposition'] = 'attachment; filename=test.zip'
    response['Content-Length'] = temp.tell()
    temp.seek(0)
    return response

我收到此错误:

enter image description here

0 个答案:

没有答案
相关问题