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))
I can feel you forgetting me。。 有一种默契叫做我不理你,你就不理我