python读取excel表格上的值(eclipse+pydev)

hd1439 2013-03-15 11:28:58
import xlrd

class openExcel():
#读取Excel表
def rExcel(self,inFile):
rFile = xlrd.open_workbook(inFile)
#获取工作表
table = rFile.sheet_by_name('test')
#获取行数、列数
rowCounts = table.nrows - 1
colCounts = table.ncols
print(rowCounts)
#循环获取列表数据
for i in range(rowCounts):
print(table.row_values(i))

if __name__== '_main_':
t = openExcel()
t.rExcel('test.xls')


eclipse+pydev,运行后在console怎么没有读取到excel表格的值
...全文
261 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hd1439 2013-03-19
  • 打赏
  • 举报
回复
引用 6 楼 feiyuren 的回复:
引用 4 楼 hd1439 的回复:username = 'root' tn.write(username + str('\n')) TypeError: 'in <string>' requires string as left operand, not bytes 这个错误什么原因啊,怎么解决 在哪一行里出现的问题呢,是你贴出来的这两句里的吗 ……
已经解决了,谢谢
hd1439 2013-03-18
  • 打赏
  • 举报
回复
有知道的吗?
feiyuren 2013-03-18
  • 打赏
  • 举报
回复
引用 4 楼 hd1439 的回复:
username = 'root' tn.write(username + str('\n')) TypeError: 'in <string>' requires string as left operand, not bytes 这个错误什么原因啊,怎么解决
在哪一行里出现的问题呢,是你贴出来的这两句里的吗
黑石课堂 2013-03-15
  • 打赏
  • 举报
回复
angel_su 2013-03-15
  • 打赏
  • 举报
回复
if判断句为假,所以内层代码没有执行。'__main__'要改一下,前后都是双下划线才对...
hd1439 2013-03-15
  • 打赏
  • 举报
回复
username = 'root' tn.write(username + str('\n')) TypeError: 'in <string>' requires string as left operand, not bytes 这个错误什么原因啊,怎么解决
hd1439 2013-03-15
  • 打赏
  • 举报
回复
引用 1 楼 angel_su 的回复:
if判断句为假,所以内层代码没有执行。'__main__'要改一下,前后都是双下划线才对...
谢谢

37,742

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧