本文介绍了从python中的excelsheet读取特定的单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的 Python 脚本中的 excelsheet 中获取特定的单元格值.我遇到了 xlrdxlwtxlutils 模块,用于读取/写入 excelsheet.

I want to get particular cell values from excelsheet in my python script.I came across xlrd, xlwt, xlutils modules for reading/writing to/from excelsheet.

我在第一列的 3 个单元格中创建了 myfile.xls,您好,您好.

I created myfile.xls with hello, how in first column's 3 cells.

示例代码:-

import xlrd

workbook = xlrd.open_workbook('myfile.xls')
worksheet = workbook.sheet_by_name('Sheet1')
num_rows = worksheet.nrows - 1
curr_row = -1
while curr_row < num_rows:
        curr_row += 1
        row = worksheet.row(curr_row)
        print row

输出:-

[text:u'hi']
[text:u'hello']
[text:u'how']

我想从 excelsheet 中读取特定的单元格值,有人可以建议我这样做吗?

I want to read specific cell values from excelsheet, can someone suggest me if there is a way to do that?

推荐答案

要访问特定单元格的值,您将使用:

To access the value for a specific cell you would use:

value = worksheet.cell(row, column)

这篇关于从python中的excelsheet读取特定的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:11