本文介绍了非常简单的程序崩溃,Python 3.5和spyder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

推荐答案

似乎您正在使用ipython.

It seems that you are using ipython.

根据此页面: https://github.com/ipython/ipython/issues/9168

您可能会遇到一个已知问题,并将在下一发行版中修复.顺便说一句,当我在终端中运行该程序时,该程序不会崩溃.

you might run into a know issue and will be fixed in the next release. By the way, that program does not crash when I am running it in terminal.

这篇关于非常简单的程序崩溃,Python 3.5和spyder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:05