python-Django:Ajax提交多文件上传

后端View.py:
from django.http import HttpResponse,JsonResponse
import pandas as pd

def csv(request):
new_list = []
fs = request.FILES.getlist(‘myfiles’)

length = len(fs)
for i in range(length):
    print(i)
    data = pd.read_csv(fs[i])
    new_list.append(data)
#合并表
df = pd.concat(new_list)
#新的表名
new_filename = r'/Users/liangchen/study/django/excel_file/new.xls'
# 写入到一个新excel表中
df.to_excel(new_filename, index=False)

return HttpResponse('ajaxOK')

前端:

index




你可能感兴趣的:(python-Django:Ajax提交多文件上传)