给pandas的DataFrame存到excel文件里并添加表格框线。
主要使用styleframe包。
details见代码。
# -*- coding: utf-8 -*- """ Created on Sun Mar 17 19:55:27 2019 @author: Fanxiaolei """ import pandas as pd from styleframe import StyleFrame data=[{"name":"Amay","age":20,"result":80}, {"name":"Tom","age":32,"result":90}] df=pd.DataFrame(data) sf=StyleFrame(df) ew=sf.ExcelWriter(r'C:\Users\FanXiaoLei\Desktop\1.xlsx') sf.to_excel(ew) ew.save()
效果如图: