热门话题

Php 研究室

请教xls数据导入问题    作者:lucyinparis发表于2009-10-29 03:24:25

	   

我写了下面的代码用来导入xls的数据,运行后总是有错,错在哪里呢?谢谢呢

import xlrd
book = xlrd.open_workbook("C:\Documents and Settings\TransactionsDownloadExcell.xls")
sh = book.sheet_by_index(0)
for r in range(sh.nrows)[1:]:
print sh.row(r)[:4]

lucyinparis回复于2009-11-06 20:02:59
哦,成功了,原来是这样写的。 fobj = file(r'c:/TransactionsDownloadExcell.txt') lines = fobj.readlines() for line in lines: print line 谢谢叻:)
lucyinparis回复于2009-11-03 04:20:45
你的意思……是不是这样写 book = xlrd.open_workbook('C:\TransactionsDownloadExcell.xls', 'r') 可我每次还是这个错误 SyntaxError: EOF while scanning triple-quoted string literal
lucyinparis回复于2009-11-03 02:25:17
谢谢老老仙。 不过,我没太看懂哎,这里用的是绝对路径啊,怎么加r上去啊?直接加么??
xieaotian回复于2009-11-02 13:42:36
book = xlrd.open_workbook("C:\Documents and Settings\TransactionsDownloadExcell.xls") 路径前面加一个r试试看。
回复主题
Copyright © 2008-2010 版权所属:中国Python联盟 www.okpython.com
京ICP备08012290号 村长QQ:81356625 E-mail:xieaotian@163.com