赞
踩
Pandas是一个基于NumPy的Python数据分析库,可以从各种文件格式如CSV、JSON、SQL、Excel等导入数据,并支持多种数据运算操作,如归并、再成形、选择等。
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install pandas
视图:
from django.shortcuts import render from django.http import HttpResponse from antproject.settings import BASE_DIR import pandas as pd # Create your views here. def hello(request): return HttpResponse("this is hello/") def show_excel(request): df=pd.read_excel(BASE_DIR / "data/score.xlsx") cont=""" <table> <tr> <th>学号</th> <th>姓名</th> <th>语文</th> <th>数学</th> <th>英语</th> </tr> """ for idx, row in df.iterrows(): cont += f""" <tr> <td>{row.学号}</td> <td>{row.姓名}</td> <td>{row.语文}</td> <td>{row.数学}</td> <td>{row.英语}</td> </tr> """ cont += """ </table> """ return HttpResponse("this is score" + cont)
from django.contrib import admin
from django.urls import path
from antapp import views
urlpatterns = [
path("hello/", views.hello),
path("show_excel/",views.show_excel),
]
pip install openpyxl
以下是excel原文件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。