使用xlrd从excel工作表导入python中的数字列表

使用xlrd从excel工作表导入python中的数字列表,python,excel,xlrd,Python,Excel,Xlrd,我是python的绝对初学者,我想主要使用它从excel数据开始使用matplotlib生成2D绘图 假设我有一张excel表格,第一列的前四行有数字10、20、30、40;我想用这些数字创建一个python列表 我试着: from xlrd import open_workbook book = open_workbook('filepathname') sheet = book.sheet_by_index(0) list = [] for row in range(0,4): l

我是python的绝对初学者,我想主要使用它从excel数据开始使用matplotlib生成2D绘图

假设我有一张excel表格,第一列的前四行有数字10、20、30、40;我想用这些数字创建一个python列表

我试着:

from xlrd import open_workbook

book = open_workbook('filepathname')
sheet = book.sheet_by_index(0)

list = []
for row in range(0,4):
   list.append(str(sheet.cell(row,0)))
为了创建具有这些值的列表。。。但是当我试图打印它时,我得到了

['number:10.0', 'number:20.0', 'number:30.0', 'number:40.0']
我该怎么做才能得到这样的东西呢

['10.0', '20.0', '30.0', '40.0']
所以它被认为是一个纯数字的列表?有没有一种方法仍然使用xlrd呢?

怎么样

from xlrd import open_workbook

book = open_workbook('filepathname')
sheet = book.sheet_by_index(0)

list = []
for row in range(0,4):
    # Remove str(...) if you want the values as floats.
    list.append(str(sheet.cell(row,0).value))  # Changed this line
参考:

特别是,您需要
Cell.value
属性

sheet.cell(row, col).value

将在单元格中提供值。

听起来你根本不是初学者!尤其是“绝对”的!问一个问题没有什么丢脸的,即使是一个简单的问题,即使你是Python方面的专家!任何人在任何时候都可以有任何问题。