一、将excel文件存为csv格式
代码如下:
1 import pandas as pd 2 def cscx_to_csv_pd(): 3 data_csc = pd.read_excel(‘E:\Spyder\Python成绩登记信计.xlsx‘, index_col=0) 4 data_csc.to_csv(‘E:\Spyder\Python成绩登记信计.csv‘, encoding=‘gbk‘) 5 if __name__ == ‘__main__‘: 6 cscx_to_csv_pd()
运行结果如下:
并将优秀变成90分,良好80分,及格60分,没有交0分
代码如下:
1 import os 2 import os.path 3 4 csvpath=os.getcwd()+"\\" 5 f=open(‘E:\Spyder\Python成绩登记信计1.csv‘,encoding="gbk") 6 content = f.read() 7 f.close() 8 t = content.replace("优秀","90分") 9 t = content.replace("良好","80分") 10 t = content.replace("合格","60分") 11 t = content.replace("不合格","0分") 12 with open("E:\Spyder\Python成绩登记信计1.csv","w",encoding=‘gbk‘) as f1: 13 f1.write(t)
运行结果如下:
二、运用GGI将上述csv文件用网页显示
结果如下:
三、Python123成绩
Python之 将excel文件存为csv格式,运用GGI将csv文件用网页显示
原文:https://www.cnblogs.com/slj-xt/p/12953528.html