Python读写excel文件
来源:互联网 发布:淘宝客服工资一般多少 编辑:程序博客网 时间:2024/05/16 11:17
下载xlrd模块,将下载完解压后的 xlrd-0.9.4 文件夹copy到Python目录下的lib中,然后eclipse里Windows——preferences——PyDev——Interpreters——Python Interpreter——libraries——New Folder 将xlrd-0.9.4引入即可import xlrd。【经过验证的代码】
import xlrd
fname = "test.xlsx"
bk = xlrd.open_workbook(fname)
shxrange = range(bk.nsheets)
try:
sh = bk.sheet_by_name("Sheet1")
except:
print "no sheet in %s named Sheet1" % fname
#获取行数
nrows = sh.nrows
#获取列数
ncols = sh.ncols
print "nrows%d,ncols %d" % (nrows,ncols)
#获取第一行第一列数据
cell_value = sh.cell_value(1,0)
print cell_value
#print cell_value
row_list = []
row_list_1 = []
#获取各行数据
for i in range(0,nrows):
row_data = sh.row_values(i) #获取一行数据,用sh.cell_value()可只获取一个数据。
print row_data
row_list.extend(row_data)
printrow_list- python读写Excel文件
- python读写excel文件
- Python读写excel文件
- Python 读写Excel文件
- python读写excel文件
- Python读写excel文件
- python读写Excel文件
- Python读写excel文件
- python读写excel文件
- python读写excel文件
- python读写excel文件
- python 操作excel 读写文件
- 用Python读写Excel文件
- 用Python读写Excel文件
- 用Python读写Excel文件
- 用Python读写Excel文件
- python-23-读写excel文件
- python之读写excel文件
- SpringMVC之Controller常用注解功能全解析
- 《加密与解密》学习笔记(二) - 加密算法和PE文件
- EM算法及OpenCV源码分析
- java 程序计数器
- 三十分钟掌握STL
- Python读写excel文件
- Nodejs sublime text 3安装与配置
- java8 ArrayList源码阅读
- Hello World!
- C# 16进制与字符串、字节数组之间的转换
- hdu 2077 汉诺塔IV
- 我从华为身上学到的项目管理经验 -- 概述篇
- 命令窗口导出oracle数据库的方法及常见问题解决方法
- 【UE4学习】09_SteamVR/Vive/VR 模式下 满屏/去黑边