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("C:/Users/25764/Anaconda3/Lib/site-packages/itchat/components/Python成绩登记信计.csv","r") ls=[] for line in fr: line=line.replace("\n","") ls.append(line.split(",")) fr.close() fw=open("C:/Users/25764/Anaconda3/Lib/site-packages/itchat/components/Python成绩登记信计.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()