#!user/bin/python3
#coding:utf-8
import xlrd
file = '这里填要读取的文件的绝对路径'
wb = xlrd.open_workbook(filename=file)
print(u'表格中Sheet为:',wb.sheet_names())
# 通过索引获取表格
sheet1 = wb.sheet_by_index(0)
# 获取行内容
rows1 = sheet1.row_values(1,1)
rows2 = sheet1.row_values(2)
print(rows1)
print(rows2)
# 获取列内容
cols1 = sheet1.col_values(1)
cols2 = sheet1.col_values(2)
print(cols1)
print(cols2)
'''''''''
#获取表格里的内容,三种方式
print(sheet1.cell(1,0).value)
print(sheet1.cell_value(1,0))
print(sheet1.row(1)[0].value)
'''
Python 读取xlsx表格
猜你喜欢
转载自blog.csdn.net/weixin_42116406/article/details/83827765
今日推荐
周排行