小编Sir*_* Li的帖子

如何使用Python从Excel文件读取一列?

我想在excel的一栏中读取数据,这是我的代码:

import xlrd

file_location = "location/file_name.xlsx"

workbook = xlrd.open_workbook(file_location)

sheet = workbook.sheet_by_name('sheet')

x = []

for cell in sheet.col[9]:

    if isinstance(cell, float):

        x.append(cell)

print(x)
Run Code Online (Sandbox Code Playgroud)

这是错误的,因为工作表中没有名为col [col.num]的方法,但是我只想从第8列(H列)中提取数据,我该怎么办?

python excel

6
推荐指数
2
解决办法
3万
查看次数

标签 统计

excel ×1

python ×1