如何运行xlrd-0.9.3

时间:2015-03-08 02:17:42

标签: python json excel csv

当我运行这个python文件时,我在控制台中收到错误:文件“Documents / test.py”,第4行     xlrd-0.9.3 \ xlrd \              ^ SyntaxError:语法无效

如何加载xlrd包? 以下是我从http://www.python-excel.org/

下载软件包的地方

注意:我下载的xlrd-0.9.3文件夹与此.py文件位于同一级别:

import urllib
xlrd-0.9.3\xlrd\
import xlrd

url = "http://us.spindices.com/idsexport/file.xls?hostIdentifier=48190c8c-42c4-46af-8d1a-0cd5db894797&selectedModule=PerformanceGraphView&selectedSubModule=Graph&yearFlag=all&indexId=10001901"

urllib.urlretrieve(url, "test1.xls")


rb = xlrd.open_workbook('test1.xls',formatting_info=True)
sheet = rb.sheet_by_index(0)
for rownum in range(sheet.nrows):
row = sheet.row_values(rownum)
for c_el in row:
    print c_el

1 个答案:

答案 0 :(得分:0)

试试xlrd套餐:

import xlrd
rb = xlrd.open_workbook('document.xls',formatting_info=True)
sheet = rb.sheet_by_index(0)
for rownum in range(sheet.nrows):
    row = sheet.row_values(rownum)
    for c_el in row:
        print c_el