IDLE 中的不同输出和 Spyder IDE 中的 IPython 控制台。可能的原因
Different outputs in IDLE and IPython console in Spyder IDE. Possible reasons
我的一个 function/command 开始表现异常。
a = [[1,2,3,4,5],[3,4,5,6,7,8,9],[5],[1,2,3,6,7,8,9]]
b = [[1,4],[6,9]]
print ([[i for i in s if not any(l <= i <= h for l, h in b)] for s in a])
预期输出:
[[5], [5], [5], []]
IDLE 和 codeskulptor 中的输出 (https://py3.codeskulptor.org/) :
[[5], [5], [5], []]
Spyder IDE 中的输出(在 Ipython 控制台中)是
[[], [], [], []]
代码在昨天 EoD 之前运行良好。我今天再次启动我的笔记本电脑并开始出现这种差异。我的 python 安装是通过 Anaconda 进行的。 Python版本3.6.6(在IDLE和Spyder中均显示)Spyder版本为3.3.1
作为最后的手段,我曾多次尝试重启笔记本电脑,但似乎找不到造成这种差异的原因
(这里是 Spyder 维护者) 如果在你的代码之前,我可以重现你在 Spyder 中看到的输出 运行
from numpy import any
由于您声称在内核重启后得到相同的结果,这意味着您已经激活了
中的选项
Tools > Preferences > IPython console > Graphics > Automatically load Pylab and NumPy modules
因此,请停用该选项以使用内置 any
获得预期的输出。
我的一个 function/command 开始表现异常。
a = [[1,2,3,4,5],[3,4,5,6,7,8,9],[5],[1,2,3,6,7,8,9]]
b = [[1,4],[6,9]]
print ([[i for i in s if not any(l <= i <= h for l, h in b)] for s in a])
预期输出:
[[5], [5], [5], []]
IDLE 和 codeskulptor 中的输出 (https://py3.codeskulptor.org/) :
[[5], [5], [5], []]
Spyder IDE 中的输出(在 Ipython 控制台中)是
[[], [], [], []]
代码在昨天 EoD 之前运行良好。我今天再次启动我的笔记本电脑并开始出现这种差异。我的 python 安装是通过 Anaconda 进行的。 Python版本3.6.6(在IDLE和Spyder中均显示)Spyder版本为3.3.1
作为最后的手段,我曾多次尝试重启笔记本电脑,但似乎找不到造成这种差异的原因
(这里是 Spyder 维护者) 如果在你的代码之前,我可以重现你在 Spyder 中看到的输出 运行
from numpy import any
由于您声称在内核重启后得到相同的结果,这意味着您已经激活了
中的选项Tools > Preferences > IPython console > Graphics > Automatically load Pylab and NumPy modules
因此,请停用该选项以使用内置 any
获得预期的输出。