python批处理多个excel文件,得出所有excel文件中某一列的和,具体程序如下:文件都在D:/excel中

import os
import xlrd
os.chdir('D:\\excel')
for j in os.popen('dir'):
j=j.strip('\n')
wb=xlrd.open_workbook(j)
table=wb.sheet_by_index(0)
numh=0.0
for i in range(1,table.nrows):
numh=table.cell(rowx=i,colx=1).value+numh

print numh

哪里错了
是不是文件迭代出错

import os,xlrd
numh=0.0
for f in os.listdir('D:\\excel'):
print "file:",f
wb=xlrd.open_workbook(os.path.abspath(f))
table=wb.sheet_by_index(1)
for r in range(table.nrows):
numh=table.cell(r,0).value+numh
print 'numh:',numh

来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考