Python输出窗口在运行后立即在eclipse中消失

时间:2014-12-20 08:13:44

标签: python eclipse eclipse-plugin pydev

我使用eclipse IDE和pydev插件进行python开发。在eclipse中,当我运行以下代码片段时,程序输出窗口出现并立即消失。使用 ecliple 时如何解决这个问题(不是通过终端或命令提示符使用)?



import turtle 
wn = turtle.Screen() 
alex = turtle.Turtle() 

alex.forward(50) 
alex.left(90) 
alex.forward(30) 

wn.mainloop()




1 个答案:

答案 0 :(得分:0)

那是因为你得到一个错误,它与eclipse无关:

AttributeError: '_Screen' object has no attribute 'mainloop'

如果你想连续循环使用while循环或for循环:

import turtle
while True:
    wn = turtle.Screen()
    alex = turtle.Turtle()

    alex.forward(50)
    alex.left(90)
    alex.forward(30)

如果你想看到保持屏幕,请使用exitonclick()

wn.exitonclick()

the docs

相关问题