- 帖子
- 7
- 精华
- 0
- 积分
- 33
- 阅读权限
- 10
- 注册时间
- 2017-5-16
- 最后登录
- 2017-5-27
|
xlrd是只能读数据吗?xlwt是只能写数据吗?
使用哪个才能达到删除的目的?
数据中是字母和数字
#删除奇数列的数据
# -*- 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'
自己试了delete、del都不管用,请问问题出在哪了
|
|