内置函数不能与Spyder一起使用

编程入门 行业动态 更新时间:2024-10-24 14:16:32
本文介绍了内置函数不能与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:

  • 内核硬启动( 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一起使用

    本文发布于:2023-10-04 04:12:21,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:能与   函数   Spyder

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!