1.安装xlrd
获取xlrd的安装包,找到setup.py安装程序路径
打开cmd,进入setup.py安装程序路径下,执行:
python setup.py install
3.获取Excel表中的内容,
Excel命名为“newnote.xls”第一个sheet页命名为“note”,路径是D:\zidonghua
Excel内容如下:
输出第二行、第二列的内容,代码如下:
#coding=utf-8
#读取 excel-read
import xlrd
#打开Excel,路径双斜线
wb=xlrd.open_workbook("D:\\zidonghua\\newnote.xls")
#获取sheet页
sh=wb.sheet_by_name('note')
#获取表中的内容 cell_value(i,j) 获取的为第i+1行,j+1列
user=sh.cell_value(1,1)
print user