python中的len函数不再计算列表的长度

问题描述 投票:0回答:1

我在colab中编写了这个简单的代码:

len([2,4 ,44])
令人惊讶的是这个错误返回:

<ipython-input-10-2ba3beee1295> in <cell line: 1>()
----> 1 len([2,4 ,44])

TypeError: 'int' object is not callable

为什么?

len
不是应该计算列表的长度吗?

python google-colaboratory
1个回答
0
投票

错误表明您已将 int 变量分配给 len:

你的代码 len([2,4 ,44]) 是正确的

© www.soinside.com 2019 - 2024. All rights reserved.