“ TypeError:内置操作的错误参数类型” [英] "TypeError: bad argument type for built-in operation"
问题描述
在何种情况下,Python会引发此错误:
In what cases would Python throw this error:
"TypeError: bad argument type for built-in operation"
在以下代码行中报告了错误:
The error was reported in this line of code:
csv.reader(open(file_name), dialect=dialect)
我尝试重现它,但最接近的是此错误:
I've tried to reproduce it but the closest I got was this error:
"TypeError: coercing to Unicode: need string or buffer, bool found"
我已经在Linux上尝试使用Python2.7和Python 2.5和Windows XP上的Python 2.4
I've tried with Python2.7 and Python 2.5 on Linux and Python 2.4 on Windows XP
推荐答案
Python中的 csv.reader
2.4有已知错误;参见 http://mail.python.org/pipermail/tutor/2008- January / 059758.html
The csv.reader
in Python 2.4 has known bugs; see http://mail.python.org/pipermail/tutor/2008-January/059758.html
通常,内置操作的错误参数类型会在各处出现,因为这是由 PyErr_BadArgument
CPython API调用。这意味着回溯不会有太大用处,因为C代码中引发了异常。调试的最佳选择是在调试器下运行Python并在 PyErr_BadArgument
上设置断点。
In general, "bad argument type for built-in operation" crops up all over the place because it's the exception text generated by PyErr_BadArgument
CPython API call. This means that the traceback won't be much use because the exception is raised in C code. Your best bet for debugging is to run Python under a debugger and set a breakpoint on PyErr_BadArgument
.
这篇关于“ TypeError:内置操作的错误参数类型”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!