将包含多个sheet的表格分割为单个sheet表格,并以sheet的名称进行命名,具体代码如下:
#导入包
import pandas as pd
workxls=pd.read_excel(r"D:\Practice\workxls.xlsx",sheet_name=None) #设置sheet_name=None,则返回所有的sheet表,
# 类型为字典,键值为sheet名称;不设置则默认返回第一个sheet表格,为DataFrame类型。
print(type(workxls))
print(workxls.keys())
for i in workxls.keys():
print(i)
sheeti=workxls.get(i)
print(sheeti.columns)
outdir="D:\\Practice\\outsheet\\"+i+'.xlsx'
print(outdir)
sheeti.to_excel(outdir,index=False)