xx = 0
n = 4294967295
while xx <= n:
print("xx = ", xx, bin(xx))
xx += 1
这导致以下追溯:
File "<ipython-input-2-0c9d04ddbbc6>", line 1, in <module>
runfile('C:/Users/Allen/Documents/Python Scripts/crunchy.py', wdir='C:/Users/Allen/Documents/Python Scripts')
File "C:\Users\Allen\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
execfile(filename, namespace)
File "C:\Users\Allen\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Allen/Documents/Python Scripts/crunchy.py", line 11, in <module>
print("xx = ", xx, bin(xx))
File "C:\Users\Allen\Anaconda3\lib\site-packages\ipykernel\iostream.py", line 317, in write
self._buffer.write(string)
ValueError: I/O operation on closed file
答案 0 :(得分:1)
您似乎正在使用ipython。
根据此页面:https://github.com/ipython/ipython/issues/9168
您可能会遇到已知问题,并将在下一版本中修复。顺便说一句,当我在终端中运行它时,该程序不会崩溃。
答案 1 :(得分:0)
( Spyder开发人员)此错误不是Spyder错误,而是ipykernel
错误。它已在2016年8月发布的ipykernel
版 4.4 中修复。
因此,请务必在终端中运行此命令(即ipykernel
)
cmd.exe
conda update ipykernel