解决Python中TypeError: unbound method 问题
2014-12-10 11:23
846 查看
今天执行了下之前写的Python接口文件,源码如下,
在运行时报错: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)
__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)
相关文章推荐
- 快速解决Python问题:TypeError: list indices must be integers or slices, not str
- TypeError: unhashable type: 'matrix'解决方法 以及 Python3下map函数的显示问题、 python numpy中nonzero()的用法
- Python出现TypeError: file() argument 1 must be encoded string without NULL bytes, not str问题解决
- 在Python中TypeError: object() takes no parameters新手问题的解决办法
- Python学习笔记:学习爬虫时遇到的问题TypeError: cannot use a string pattern on a bytes-like object 与解决办法
- Python3.5 TypeError: cannot use a string pattern on a bytes-like object问题解决
- “Uncaught TypeError: Cannot call method 'createChild' of undefined" 问题的解决
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- python问题:IndentationError:expected an indented block错误解决
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- chrome浏览器Uncaught TypeError: object is not a function问题解决
- python import 包问题:TypeError: 'module' object is not callable
- python问题:IndentationError:expected an indented block错误解决
- 解决python中TypeError: not enough arguments for format string
- python2.7 使用super关键词 报错 TypeError: must be type, not classobj 解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- 路由软件 zebra-0.95a 在linux下面编译出现问题的解决(error: dereferencing pointer to incomplete type)
- greta的问题及解决: LIBCMTD.lib(_wctype.obj) : error LNK2005: _iswspace already defined in xxx.obj
- chrome浏览器Uncaught TypeError: object is not a function问题解决
- python问题:IndentationError:expected an indented block错误解决