zoukankan      html  css  js  c++  java
  • csv->html

    seg1='''
    <!DOCTYPE HTML>
    <html>
    <body>
    <meta charset=gb>
    <h2 align=center>Python成绩登记信计</h2>
    <table border='1' align="center" width=70%>
    <tr bgcolor='orange'>
    '''
    seg2="</tr>
    "
    seg3="</table>
    <body>
    </html>"
    def fill_data(locls):
        seg='<st><td align="center">{}</td><td align="center">
        {}</td><td align="center">{}</td><tdalign="center">
        {}</td></tr>
    '.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("
    ","")
        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>
    <th 
    width="25%">{}</th>
    <th width="25%">{}</th>
    <th
     width="25%">{}</th>
    '''.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()
    

      

  • 相关阅读:
    wxpython的安装

    拓扑排序
    树,二叉树,森林,三者的转换
    二叉树的遍历
    最短路径
    图的遍历
    图的最小生成树
    哈夫曼树的应用
    哈夫曼树
  • 原文地址:https://www.cnblogs.com/670ling/p/13089228.html
Copyright © 2011-2022 走看看