您的位置:首页 > 编程语言 > Python开发

解决Python中TypeError: unbound method 问题

2014-12-10 11:23 846 查看
今天执行了下之前写的Python接口文件,源码如下,

__author__ = 'Administrator'
#coding:utf-8
from readData import dictionary
readIt = {}
readIt = dictionary.onlyCellValue("E:\python\API\eadData.xls", "Sheet1", 1)
print readIt
for key in readIt:
    temp_list = readIt[key]
    for i in range(0, len(temp_list)):
        print "第"+(i+1)+"个参数为"+temp_list[i]


在运行时报错:TypeError: unbound method onlyCellValue() must be called with dictionary instance as first argument (got str instance instead)

后经在网上查看,发现时由于调用其他类时,未在后面添加括号,添加括号后,运行正常。这是由于未添加括号情况下,未被认为是类的实例,故报此错

改正后的:readIt = dictionary().onlyCellValue("E:\python\API\eadData.xls", "Sheet1", 1)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐