Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中从excel工作表中读取数据?_Python_Selenium_Read Data - Fatal编程技术网

如何在python中从excel工作表中读取数据?

如何在python中从excel工作表中读取数据?,python,selenium,read-data,Python,Selenium,Read Data,在selenium python框架中是否有任何python脚本可以从excel工作表读取数据 我已经写了下面的代码,但我不认为它完全正确 def getcell(行、列): 打印(表格)试试。用于读取ms excel工作表的python模块。下面是其自述文件中提供的一个简单示例 import xlrd book = xlrd.open_workbook("myfile.xls") print "The number of worksheets is", book.nsheets print "

在selenium python框架中是否有任何python脚本可以从excel工作表读取数据

我已经写了下面的代码,但我不认为它完全正确

def getcell(行、列):

打印(表格)

试试。用于读取ms excel工作表的python模块。下面是其自述文件中提供的一个简单示例

import xlrd
book = xlrd.open_workbook("myfile.xls")
print "The number of worksheets is", book.nsheets
print "Worksheet name(s):", book.sheet_names()
sh = book.sheet_by_index(0)
print sh.name, sh.nrows, sh.ncols
print "Cell D30 is", sh.cell_value(rowx=29, colx=3)
for rx in range(sh.nrows):
    print sh.row(rx)

嗨,3R50N 1,它成功了。我有一个疑问,我们是否可以编写代码,其中有一个excel工作表,我们必须使用tc id读取多行。例如:我必须通过传递参数tc01来读取一行。是的,它会。继续并在程序中嵌入模块。请接受答案,如果它解决了您的问题,请向上投票。您可以帮助我使用tc id的脚本写读多行。我不认为这个问题与Selenium有任何关系(它可能只是间接地与测试自动化有关)。请相应地编辑问题和标签。谢谢。你尝过熊猫吗?为了解决你的问题似乎很自然?
import xlrd
book = xlrd.open_workbook("myfile.xls")
print "The number of worksheets is", book.nsheets
print "Worksheet name(s):", book.sheet_names()
sh = book.sheet_by_index(0)
print sh.name, sh.nrows, sh.ncols
print "Cell D30 is", sh.cell_value(rowx=29, colx=3)
for rx in range(sh.nrows):
    print sh.row(rx)