python 獲取Excel中所有sheets名稱

2022-06-25 12:03:14 字數 526 閱讀 9074

在這裡不做過多的敘述,用**更為直觀的展示執行過程:

第一種方法:

#獲取檔案的sheep_name

import pandas as pd

sheep_name=pd.excelfile('my.xlsx')

sheet_names=sheep_name.sheet_names

print(sheet_names)

第二種方法:

#獲取檔案的sheep_name

import pandas as pd

df=pd.read_excel('my.xlsx',engine='openpyxl',sheet_name=none) #要想獲取所有sheets名稱 這個必須設定為none

C 獲取Excel中所有的Sheet名稱

注意 自己試了一下下面的方法,稍微改變了一下,一直都報錯,後來發現問題在於 自己習慣了陣列等集合的索引都是從0開始,而excel中都是從1開始的。這一點,下面的 中有體現。原文連線 獲取第乙個sheet excel.worksheet sheet excel.worksheet mybook.she...

Python獲取excel列表資料

import xlrd import time 設定路徑 file path r c users viruser.v desktop desktop worlddata finds.xlsx utf 8編碼 xlrd.book.encoding utf 8 獲取資料 data xlrd.open w...

python操作excel獲取內容

背景 從excel表中獲取請求url 請求資料 請求型別 預期結果 因此,需要學會如何使用python從excel獲取這些資訊 coding utf 8 import xlrd 建立物件時,獲取對應excel 讀取excel行數 獲取單元格內容 class operationexcel def in...