#删除奇数列的数据
# -*- coding:utf-8 -*-
import xlrd
f='20170324.XLS'
wb=xlrd.open_workbook(f)
try:
sh=wb.sheet_by_name('Sheet1')
except:
print 'no Sheet1'
ncols=sh.ncols
print ncols
for i in range(1,ncols):
sh.col(i).Delete()
i+=2
以下是结果:
234
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\111.py", line 12, in <module>
sh.col(i).Delete()
AttributeError: 'list' object has no attribute 'Delete'