发现一个问题,为什么同一段python代码在IDLE中可以正确运行,在力扣中却报错了
报错:int() argument must be a string, a bytes-like object or a number, not ‘builtin_function_or_method‘
问题是在global声明一个变量然后将它和另一个整形比较时出现的。
global max
if(max < temp)
max = temp
解决方法:
直接将max变量声明为数组max[0],即可为全局变量,不用再进行global声明
...
原创
2022-03-23 21:37:34 ·
1988 阅读 ·
0 评论