0
我试图把动态值作为参数在xlrd的open_workbook()函数中,但它给出错误。 我的示例代码:Python中xlrd模块的open_workbook()的参数是否需要浮动值?
** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * *
进口xlrd,OS 文件路径= R'C:\用户\ JJ \桌面\ JustForTest \ 2012_09_10'
为根目录,文件在os.walk文件(文件路径):
abc=files[0] # To convert List to string, files will be like ['Samplexyx.xls']
wb=xlrd.open_workbook(abc)
sh=wb.sheet_by_index(0)
for rownum in range(sh.nrows):
print(sh.row_values(rownum))
** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * *
在上面的代码中,ABC的值动态地变化。 当我运行上面的代码,它给错误:IOError:[Errno 2]没有这样的文件或目录:'Samplexyx.xls'
我是使用xlrd和Python的新手。我应该如何使用xlrd和python动态打开xls文件?
感谢Joran。我真的很感激。 – jags