Python +;的操作数类型不受支持:';dict';和';int';
有点奇怪 有人能解释一下这条Python +;的操作数类型不受支持:';dict';和';int';,python,typeerror,Python,Typeerror,有点奇怪 有人能解释一下这条TypeError信息吗 csvRow.append(len(calls["outbound"] + len(calls["inbound"]))) TypeError: unsupported operand type(s) for +: 'dict' and 'int' 当我执行以下操作时,我不会遇到任何问题,它会按预期运行: totalinbound = len(calls["inbound"]) totaloutbound = len(calls["outb
TypeError
信息吗
csvRow.append(len(calls["outbound"] + len(calls["inbound"])))
TypeError: unsupported operand type(s) for +: 'dict' and 'int'
当我执行以下操作时,我不会遇到任何问题,它会按预期运行:
totalinbound = len(calls["inbound"])
totaloutbound = len(calls["outbound"])
csvRow.append(totalinbound + totaloutbound)
你的括号没有正确平衡<代码>调用[“出站”]应位于调用
len
函数的括号内:
csvRow.append(len(calls["outbound"]) + len(calls["inbound"]))
# ^
我把一个结束语从句尾移到箭头所在的位置
否则,您将尝试添加
len(calls[“inbound”])
,并使用calls[“outbound”]
返回的dict。这是一个类型错误
您的括号未正确平衡<代码>调用[“出站”]应位于调用len
函数的括号内:
csvRow.append(len(calls["outbound"]) + len(calls["inbound"]))
# ^
我把一个结束语从句尾移到箭头所在的位置
否则,您将尝试添加len(calls[“inbound”])
,并使用calls[“outbound”]
返回的dict。这是一个类型错误
您有一个输入错误
# calculates the len of (dict + len of dict)
len(calls["outbound"] + len(calls["inbound"]))
# calculates the len of dict + len of dict
len(calls["outbound"]) + len(calls["inbound"])
你打错了
# calculates the len of (dict + len of dict)
len(calls["outbound"] + len(calls["inbound"]))
# calculates the len of dict + len of dict
len(calls["outbound"]) + len(calls["inbound"])