内置函数不能与Spyder一起使用 [英] Builtin function not working with Spyder

查看:320
本文介绍了内置函数不能与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头像。当从几秒后复制/粘贴随机代码片段来测试以发现非常奇怪的行为时,我已经陷入了这种情况 - 在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.

您可以执行以下两项操作:

There's two things you can do:


  1. 内核硬启动( ctrl +

  2. 后续这个功能请求线程,现在可以在每次运行脚本时自动清除名称空间。

  1. A hard restart of the Kernel (ctrl + .)
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆