# -*- coding: utf-8 -*-
"""
Created on Mon Apr 29 09:24:04 2019
@author: history
"""
seg1='''
<!DOCTYPE HTML>\n<html>\n<body>\n<meta charset=gb>
<h2 align=center>python成绩</h2>
<table border='1' align="center" width=70%>
<tr bgcolor='orange'>\n'''
seg2="</tr>\n"
seg3="</table>\n<body>\n</html>"
def fill_data(locls):
seg='<st><td align="center">{}</td><td align="center">\
{}</td><td align="center">{}</td><tdalign="center">\
{}</td></tr>\n'.format(*locls)
return seg
fr=open("D:/Python文件/Python成绩.xlsx.csv","r")
ls=[]
for line in fr:
line=line.replace("\n","")
ls.append(line.split(","))
fr.close()
fw=open("D:/Python文件/Python成绩.xlsx.csv.html","w")
fw.write(seg1)
fw.write('''<th width="25%">{}</th>\n<th
width="25%">{}</th>\n<th width="25%">{}</th>\n<th
width="25%">{}</th>\n'''.format(*ls[10]))
fw.write(seg2)
for i in range(len(ls)-1):
fw.write(fill_data(ls[i+1]))
fw.write(seg3)
fw.close()