ptyhon如何讀取excel數據到數組?
謝邀,代碼如下:
from openpyxl import load_workbook
#讀取路徑
book = load_workbook(filename=r"路徑.xlsx")
#讀取名字為Sheet1的表
sheet = book.get_sheet_by_name("Sheet1")
#用于存儲數據的數組
data= []
row_num = 1
while row_num <= 100 :
#將表中第一列的1-100行數據寫入data數組中
data.append(sheet.cell(row=row_num, column=1).value)
row_num = row_num + 1