今天执行了下之前写的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)
————————————————
版权声明:本文为CSDN博主「emily_and_cat」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/emily_and_cat/article/details/41843851