问题总结
1.django用post传文件,如何接收和下载?
data= request.FILES.get("file")#接收到的数据类型是<class "django.core.files.uploadedfile.InMemoryUploadedFile"> # print(data,type(data)) #<class "django.core.files.uploadedfile.InMemoryUploadedFile"> with open(r"C:Users33101Desktop12新建1111.txt","wb") as p:#这样可以写进文件,不能直接p.write(chunks()) for chunk in data.chunks(): p.write(chunk)