Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:TypeError:-:';int';和';int';_Python - Fatal编程技术网

Python:TypeError:-:';int';和';int';

Python:TypeError:-:';int';和';int';,python,Python,这是我的一个功能: def analyzeHeader(headerLine): import re matchObj = re.match("^\s*(\w+).+:\s*(\d+)\s+Name = (.+) - Type = (.+)\s*$", headerLine, re.M|re.I) if not matchObj: return None return [matchObj.group(1), matchObj.group(2), m

这是我的一个功能:

def analyzeHeader(headerLine):
    import re
    matchObj = re.match("^\s*(\w+).+:\s*(\d+)\s+Name = (.+) - Type = (.+)\s*$", headerLine, re.M|re.I)
    if not matchObj:
        return None
    return [matchObj.group(1), matchObj.group(2), matchObj.group(3), matchObj.group(4)]
然后我调用analyzeHeader:

list = analyzeHeader(headerLine)
## ....
col = int(float(list[1])) - 1 ### <== Error here
list=analyzeHeader(headerLine)
## ....

col=int(float(list[1])-1####代码没有问题。我用来执行代码的工具只涉及Python的原始int()函数。然后我所要做的就是调用原始的int()函数:
\uuuu builtin\uuuu.int()

请输入完整的错误输出,因为我无法再现错误;您是否将
int()
的子类重新分配给了
int
可能?考虑到您所做的:
list=analyzeHeader(headerLine)
您可能将
int
类型替换为其他类型。定义用户类/对象/变量时不要使用内置名称!
list = analyzeHeader(headerLine)
## ....
col = float(list[1]) - 1 ### <== OK now
c = int(col)
r = row - 1
tmp = data[r]
res = float(tmp[c]) ### Error now occurs here: "TypeError: list indices must be integers"