Bootstrap

xlrd基本操作

#coding=utf-8
import xlrd

def read_excel():
  workbook = xlrd.open_workbook('people.xlsx')
  sheet2 = workbook.sheet_by_index(0) # sheet索引从0开始
  # rows = sheet2.row_values(2)  # 获取第四行内容
  cols = sheet2.col_values(0) # 获取第三列内容
  # print rows
  # print cols

  #弹出第一个单元格无用信息
  colslist = cols.pop(0)
  for i in cols:
    print i.encode('utf-8')

  # 获取单元格内容
  # print sheet2.cell(1, 0).value.encode('utf-8')
  # print sheet2.cell_value(1, 0).encode('utf-8')
  # print sheet2.row(1)[0].value.encode('utf-8')
if __name__ == '__main__':
  read_excel()

转载于:https://www.cnblogs.com/wzjbg/p/6631746.html

;