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

2025-04-13 09:43:08
推荐回答(1个)
回答1:

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