我尝试过javatpoint.com中的这段代码
代码
# Import the xlrd module
import xlrd
# Define the location of the file
loc = ("C:\\Users\User\\Desktop\\Book1.xlsx")
# To open the Workbook
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
# For row 0 and column 0
sheet.cell_value(0, 0)
我的Excel工作表
预期输出
Name
但是输出是
>Python excel_001.py
>
程序执行没有任何错误
为什么不尝试将excel工作表读取为python中的Pandas数据框
import pandas as pd
df = pd.read_excel("C:\\Users\User\\Desktop\\Book1.xlsx")
print(df.head())