当一个 excel 文件的 sheet 比较多时候, 这时候需要获取所有的 sheet 的名字.
- xl = pd.ExcelFile(foo.xls)
- xl.sheet_names # see all sheet names
- xl.parse(sheet_name) # read a specific sheet to DataFrame
也可以直接读取所有的 sheet, 将 sheetname 设置为 None. 这时候得到的是一个 dict 结果.
- df = pandas.read_excel("/yourPath/FileName.xlsx", None);
- "df"are all sheets as a dictionary of DataFrames,
- you can verify it by run this: df.keys()
来源: http://www.bubuko.com/infodetail-2498775.html