发布时间:2019-07-16 10:09:38编辑:auto阅读(1990)
使用 xlrd 能够很方便的读取 excel 文件内容,而且这是个跨平台的库,能够在windows,linux/unix,等平台上面使用。
软件可以去这个地址http://www.lexicon.net/sjmachin/xlrd.htm下载。
importxlrd fname = "sample.xls" 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 returnNone nrows = sh.nrows ncols = sh.ncolsprint"nrows %d, ncols %d"%(nrows,ncols) cell_value = sh.cell_value(1,1)print cell_value row_list = []for i inrange(1,nrows): row_data = sh.row_values(i) row_list.append(row_data)
详细的xlrd模块帮助在他的主页上http://www.lexicon.net/sjmachin/xlrd.html
如果想彻底研究excel的话,这边有讲解excel格式的文档:
上一篇: python3.6.5源码安装
下一篇: 【python】--paramiko 连
48102
46789
37711
35037
29576
26237
25166
20203
19841
18315
5988°
6672°
6164°
6153°
7264°
6103°
6212°
6684°
6649°
8040°