python 提取excel指定单元格 保存为txt

2024-12-16 02:28:19
推荐回答(2个)
回答1:


import xlrd
tb=xlrd.open_workbook(r'd:/x/book123.xlsx')
sht=tb.sheets()[0]
for x in range(1,sht.nrows):
with open(r'd:/x/%s.txt' % sht.cell_value(x,1),'w') as f:
f.write(sht.cell_value(x,1)+','+sht.cell_value(x,5)+','+sht.cell_value(x,6)+'\n')

回答2:

数据发来看看