读书人

python读取excel表格下的值(eclipse+

发布时间: 2013-03-21 10:08:17 作者: rapoo

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

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表格的值
[解决办法]
if判断句为假,所以内层代码没有执行。'__main__'要改一下,前后都是双下划线才对...
[解决办法]
引用:
username = 'root'
tn.write(username + str('\n'))

TypeError: 'in <string>' requires string as left operand, not bytes

这个错误什么原因啊,怎么解决

在哪一行里出现的问题呢,是你贴出来的这两句里的吗

读书人网 >perl python

热点推荐