首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

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

2013-03-21 
python读取excel表格上的值(eclipse+pydev)import xlrdclass openExcel():#读取Excel表def rExcel(self,in

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

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

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

热点排行