Python程序读取excel工作表不起作用?
我试过这个代码 代码 我的Excel表格 预期产量Python程序读取excel工作表不起作用?,python,xlrd,Python,Xlrd,我试过这个代码 代码 我的Excel表格 预期产量 Name 但产出是有限的 >Python excel_001.py > 程序执行时没有任何错误为什么不尝试将excel工作表作为python中的数据帧读取 import pandas as pd df = pd.read_excel("C:\\Users\User\\Desktop\\Book1.xlsx") print(df.head()) 我没有打印它。我加了一份打印声明 # Import the xlrd modul
Name
但产出是有限的
>Python excel_001.py
>
程序执行时没有任何错误为什么不尝试将excel工作表作为python中的数据帧读取
import pandas as pd
df = pd.read_excel("C:\\Users\User\\Desktop\\Book1.xlsx")
print(df.head())
我没有打印它。我加了一份打印声明
# 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
print(sheet.cell_value(0, 0))
是否要执行
打印(sheet.cell_value(0,0))
以查看单元格0,0中的值?是的,我要查看第一列的名称。在该程序的输出(即名称)@vorspringdurchtechnik行sheet.cell_值(0,0)
没有任何影响。正如建议的那样,您可能希望将其包装为打印(…)
我知道我没有打印(sheet.cell\u值(0,0))。我当时正在做这件事。这是一个愚蠢的问题。我可以删除这个问题吗。我会被禁止再问问题吗。如果我那样做@谢谢你的帮助。这对我来说意义重大。@kenthompson:不客气。我不认为删除一个问题会阻止你再次提问。我明白了,我以为你使用的是Jupyter笔记本,你不需要单元格最后一行的打印功能
# 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
print(sheet.cell_value(0, 0))