我尝试了 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
>
程序执行没有任何错误
最佳答案
为什么不尝试在 python 中将 Excel 工作表读取为 Pandas 数据框
import pandas as pd
df = pd.read_excel("C:\\Users\User\\Desktop\\Book1.xlsx")
print(df.head())
关于Python程序读取Excel工作表不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60405075/