Home > Backend Development > Python Tutorial > Python reads excel xlrd

Python reads excel xlrd

巴扎黑
Release: 2016-12-09 10:35:47
Original
1490 people have browsed it

1. Go to https://pypi.python.org/pypi/xlrd/0.9.2 to download xlrd-0.9.2.tar.gz
2. Unzip and install, I use macos, directly python setup.py install
3 . Usage examples:

import xlrd
book = xlrd.open_workbook(fn)
#多少个sheet
print "The number of worksheets is", book.nsheets
#每个sheet的名字
print "Worksheet name(s):", book.sheet_names()
#得到第0个sheet
sh = book.sheet_by_index(0)
for rx in range(sh.nrows):
    values = sh.row(rx)
    for value in values:
        print value.ctype, value.value       #type(number, text), value
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template