[置顶] python中报错:'int' object is not callable error occur的解决方案
2017-10-03 20:01
645 查看
最近在学习python的相关知识,在写下面一段代码的时候报了一个错误:
报错如下:
这里其实是自己新建的max变量与系统内嵌的max函数产生了冲突,把自己的变量修改为maxs,即可,如下:
结果是:
所以在命名的时候注意不能和自己使用的系统函数重名,切勿再犯这样的错误,特此记录~
参考:https://stackoverflow.com/questions/11201801/why-does-the-int-object-is-not-callable-error-occur-when-using-the-sum-funct
def maxArea(height): max = 0 for k in range(len(height)): if k + 1 < len(height): for m in range(k + 1, len(height)): t = min(height[k], height[m]) c = t * abs(m - k) max = max(max, c) return max print(maxArea([1, 1]))
报错如下:
TypeError: 'int' object is not callable
这里其实是自己新建的max变量与系统内嵌的max函数产生了冲突,把自己的变量修改为maxs,即可,如下:
def maxArea(height): maxs = 0 for k in range(len(height)): if k + 1 < len(height): for m in range(k + 1, len(height)): t = min(height[k], height[m]) c = t * abs(m - k) maxs = max(maxs, c) return maxs print(maxArea([1, 1]))
结果是:
1
所以在命名的时候注意不能和自己使用的系统函数重名,切勿再犯这样的错误,特此记录~
参考:https://stackoverflow.com/questions/11201801/why-does-the-int-object-is-not-callable-error-occur-when-using-the-sum-funct
相关文章推荐
- Python:TypeError: 'int' object is not callable
- Python:TypeError: 'int' object is not callable
- 【Python】Error:'int' object is not callable
- Python: TypeError: 'int' object is not callable
- 【Python】Error:'int' object is not callable
- python3在pycharm中为什么导入random模块不能用? TypeError: 'module' object is not callable
- Python TypeError: 'module' object is not callable
- python错误: TypeError:'dict' object is not callable
- Python包导入(TypeError: 'module' object is not callable),及一定要记住Python成员函数第一个参数值是self。
- Python学习笔记 --- TypeError: 'unicode' object is not callable
- python的exit退出时,提示TypeError: 'str' object is not callable
- python错误:TypeError: 'str' object is not callable
- Python: TypeError: 'dict' object is not callable
- Python错误代码分析:莫名的[TypeError: 'int' object is not iterable]
- python import 包问题:TypeError: 'module' object is not callable
- 【Python 笔记】命名域之 TypeError 'DataFrame' object is not callable
- python错误:TypeError: 'module' object is not callable
- TypeError: 'int' object is not callable
- python TypeError: 'module' object is not callable
- python TypeError: 'int' object is not iterable