内置函数不适用于 Spyder [英] Builtin function not working with Spyder
本文介绍了内置函数不适用于 Spyder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 Python 3,6 中使用 max 函数:
I'm trying to use the max function in Python 3,6:
print('Maximum is:', max(1, 3, 2, 5, 4))
结果是
File "E:/ProgramyRobione/untitled1.py", line 2, in <module>
print('Maximum is:', max(1, 3, 2, 5, 4))
TypeError: 'int' object is not callable
我使用的是 Spyder,那一行就是代码应该做的所有事情.
I'm using Spyder and that line is all that code should do.
推荐答案
这是 Spyder 附带的一个 iPython 爆头.当我从 SO 复制/粘贴随机代码位以进行测试时,几天后才发现真正奇怪的行为时,我已经犯规了 - 在 iPython 控制台中定义的变量也将无限期地位于脚本的全局命名空间中.
This is a bit of an iPython headshot that comes with Spyder. I've fallen foul of this when copy/pasting random bits of code from SO to test only to find really odd behaviour several days later - variables defined in the iPython console will also be in the script's global namespace indefinitely.
您可以做两件事:
- 内核的硬重启(
ctrl
+.
) - 跟进这个功能请求线程,现在可以清除每次运行脚本时都会自动命名空间.
- A hard restart of the Kernel (
ctrl
+.
) - Follow up on this feature request thread where it's now possible to clear the namespace automatically every time you run a script.
这篇关于内置函数不适用于 Spyder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文