一、以下是个人成绩表格
![](https://i-blog.csdnimg.cn/blog_migrate/9222fe7e697642b25087227b928dbd1c.png)
二、下面是我的程序:
# -- coding: utf-8 --
import pandas as pd
import csv
def credit_points_sum(df,title):
df.to_csv('E:\\scores_'+title+'.csv', encoding='utf_8_sig') # index=False,header=False
sum=0
for i in range(df.shape[0]):
sum+=float(df.iloc[i][4])
print(title+':'+str(sum))
url='E://scores.html'
tb=pd.read_html(url)[1]
tb=tb[1:70]
print(tb.iloc[0][6])
tb[4].astype(float)
print(tb)
# 总学分
credit_points_sum(tb, u'总学分')
# 专选
tb_zhuanXuan=tb[tb[6]=='专选']
credit_points_sum(tb_zhuanXuan,'专选')
# 必修
tb_biXiu=tb[tb[6]=='必修']
credit_points_sum(tb_biXiu,'必修')
# 素质
tb_suZhi=tb[tb[6]=='素质']
credit_points_sum(tb_suZhi,'素质')
# 专选非限
tb_suZhi=tb[tb[6]=='专选(非限)']
credit_points_sum(tb_suZhi,'专选(非限)')
三、下面是运行的部分结果
![](https://i-blog.csdnimg.cn/blog_migrate/c5dca7852272f8a390c0a48a63b9d46e.png)
四、下面是个人下载下来的静态html
<html>
<title>学生个人总成绩查询</title>
<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="/include/style.css" type=text/css rel=stylesheet>
</head>
<body >
<center>
<table BORDER="0" cellspacing="0" height="80%">
<tr>
<td>
</td></tr>
<tr>
<td align="center">
<p><B><font size="3">重庆大学学生成绩单</font></B></p>
<p><B>学号:</B>20161590 <B>姓名:</B>谭植尹 <B>专业:</B>软件工程 <B>GPA:</B>3.22</B> </p>
<table BORDER="1" cellspacing="0" cellpadding="2" bordercolorlight="#000000"
bordercolordark="#FFFFFF" bordercolor="#FFFFFF" width="877">
<tr>
<td width="32"><b>序号</b></td>
<td width="84"><b>课程编码</b></td>
<td width="210"><b>课程名称</b></td>
<td width="43"><b>成绩</b></td>
<td width="43"><b>学分</b></td>
<td width="53"><b>选修</b></td>
<td width="52"><b>类别</b></td>
<td width="60"><b>教师</b></td>
<td width="54"><b>考别</b></td>
<td width="38"><b>备注</b></td>
<td width="140"><b>时间</b></td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
1
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE31029
</td>
<td VALIGN="center" width="210" height="23">
.NET框架及C#程序设计
</td>
<td align="center" VALIGN="center" width="43" height="23">
76
</td>
<td align="center" VALIGN="center" width="43" height="23">
2
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
专选
</td>
<td align="center" VALIGN="center" width="60" height="23">
祝伟华
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2018-12-1
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
2
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE31209
</td>
<td VALIGN="center" width="210" height="23">
DirectX图形程序设计
</td>
<td align="center" VALIGN="center" width="43" height="23">
81
</td>
<td align="center" VALIGN="center" width="43" height="23">
2
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
专选
</td>
<td align="center" VALIGN="center" width="60" height="23">
曾骏
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2019-1-10
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
3
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE21023
</td>
<td VALIGN="center" width="210" height="23">
Java EE程序设计
</td>
<td align="center" VALIGN="center" width="43" height="23">
82
</td>
<td align="center" VALIGN="center" width="43" height="23">
2
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
专选
</td>
<td align="center" VALIGN="center" width="60" height="23">
黄晟
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2018-7-16
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
4
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE31107
</td>
<td VALIGN="center" width="210" height="23">
Web开发技术
</td>
<td align="center" VALIGN="center" width="43" height="23">
95
</td>
<td align="center" VALIGN="center" width="43" height="23">
2
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
必修
</td>
<td align="center" VALIGN="center" width="60" height="23">
王成良
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2019-1-18
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
5
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE21021
</td>
<td VALIGN="center" width="210" height="23">
操作系统原理
</td>
<td align="center" VALIGN="center" width="43" height="23">
96
</td>
<td align="center" VALIGN="center" width="43" height="23">
3
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
必修
</td>
<td align="center" VALIGN="center" width="60" height="23">
洪明坚
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2018-7-15
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
6
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE11005
</td>
<td VALIGN="center" width="210" height="23">
程序设计基础
</td>
<td align="center" VALIGN="center" width="43" height="23">
84
</td>
<td align="center" VALIGN="center" width="43" height="23">
4
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
必修
</td>
<td align="center" VALIGN="center" width="60" height="23">
黄晟
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2017-1-17
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
7
</td>
<td align="center" VALIGN="center" width="84" height="23">
SE24061
</td>
<td VALIGN="center" width="210" height="23">
程序设计实训
</td>
<td align="center" VALIGN="center" width="43" height="23">
80
</td>
<td align="center" VALIGN="center" width="43" height="23">
3
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
必修
</td>
<td align="center" VALIGN="center" width="60" height="23">
雷跃明
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2017-9-11
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
8
</td>
<td align="center" VALIGN="center" width="84" height="23">
HG00046
</td>
<td VALIGN="center" width="210" height="23">
大学国文(上)
</td>
<td align="center" VALIGN="center" width="43" height="23">
82
</td>
<td align="center" VALIGN="center" width="43" height="23">
2
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
素质
</td>
<td align="center" VALIGN="center" width="60" height="23">
彭磊
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2016-12-30
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
9
</td>
<td align="center" VALIGN="center" width="84" height="23">
HG00047
</td>
<td VALIGN="center" width="210" height="23">
大学国文(下)
</td>
<td align="center" VALIGN="center" width="43" height="23">
81
</td>
<td align="center" VALIGN="center" width="43" height="23">
2
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
素质
</td>
<td align="center" VALIGN="center" width="60" height="23">
刘扬
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2017-6-20
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
10
</td>
<td align="center" VALIGN="center" width="84" height="23">
PYS10013
</td>
<td VALIGN="center" width="210" height="23">
大学物理Ⅱ-1
</td>
<td align="center" VALIGN="center" width="43" height="23">
76
</td>
<td align="center" VALIGN="center" width="43" height="23">
3.5
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
必修
</td>
<td align="center" VALIGN="center" width="60" height="23">
苏荀
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2017-7-7
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
11
</td>
<td align="center" VALIGN="center" width="84" height="23">
PYS12010
</td>
<td VALIGN="center" width="210" height="23">
大学物理实验
</td>
<td align="center" VALIGN="center" width="43" height="23">
77
</td>
<td align="center" VALIGN="center" width="43" height="23">
1.5
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
必修
</td>
<td align="center" VALIGN="center" width="60" height="23">
余沛
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2017-7-7
</td>
</tr>
<tr>
<td align="center" VALIGN="center" width="32" height="23">
12
</td>
<td align="center" VALIGN="center" width="84" height="23">
5200080
</td>
<td VALIGN="center" width="210" height="23">
大学英语(国家四级)
</td>
<td align="center" VALIGN="center" width="43" height="23">
453
</td>
<td align="center" VALIGN="center" width="43" height="23">
1
</td>
<td align="center" VALIGN="center" width="53" height="23">
正常
</td>
<td align="center" VALIGN="center" width="52" height="23">
任选
</td>
<td align="center" VALIGN="center" width="60" height="23">
国家四级
</td>
<td align="center" VALIGN="center" width="54" height="23">
正考
</td>
<td align="center" VALIGN="center" width="38" height="23">
正
</td>
<td align="center" VALIGN="center" width="140" height="23">
2017-9-12
</td>
</tr>
<tr>
<td align="center" VALIG