使用xlrd模块操作Excel

table = data.sheets()[0]
table = data.sheet_by_index(0)
print(table)
#获取正行或是整列的值
con = table.row_values(0)#[356.0, '星际牛仔', 'カウボーイビバップ', '\n                         26话 /  1998年10月23日 / 渡辺信一郎 / 矢立肇 / 川元利浩                    ', 9.1, '(4021人评分)']
con = table.col_values(2)#['cname', '星际牛仔', '攻壳机动队 S.A.C. 2nd GIG', '攻壳机动队 STAND ALONE COMPLEX', '新世纪福音战士', ]
print(con)
#获取行数与列数
nrows = table.nrows
print(nrows)#673
ncols = table.ncols
print(ncols)#6

#循环行列表数据
# for i in range(nrows):
# print(table.row_values(i))

#循环列列表数据
for i in range(ncols):
print(table.col_values(i))
#单元格索引
val = table.cell(5,5).value

# print(val2)
 

 

posted @ 2017-12-29 19:49  TAMAYURA  阅读(189)  评论(0编辑  收藏  举报