zipfile模块

class  TestView(APIView):
    def  get(self,request):
        try:
            response = HttpResponse(content_type='application/zip')
            zf = zipfile.ZipFile(response,'w')
            zf.writestr("qqqq","nihao")
            response['Content-Disposition'] = 'attachment; filename=myfile.zip'
            return response
        except  Exception as  e:
            return Response(str(e))

 

 

  

posted @ 2019-10-29 16:07  离人怎挽_wdj  阅读(131)  评论(0编辑  收藏  举报