Any way to clear python's IDLE window?

2019-01-04 17:05发布

I know there's a similar topic about python console, but I do not know if they are the same. I tried system("clear") and it didn't work here.

How do I clear python's IDLE window?

24条回答
三岁会撩人
2楼-- · 2019-01-04 17:34

Your screenshot shows you're using IDLE. cls/clear won't work for you.

查看更多
干净又极端
3楼-- · 2019-01-04 17:34

"command + L" for MAC OS X.

"contorl + L " for Ubuntu

查看更多
疯言疯语
4楼-- · 2019-01-04 17:37
>>> import os

>>>def cls():
...    os.system("clear")
...
>>>cls()

That does is perfectly. No '0' printed either.

查看更多
甜甜的少女心
5楼-- · 2019-01-04 17:39

It seems it is impossible to do it without any external library.

An alternative way if you are using windows and don't want to open and close the shell everytime you want to clear it is by using windows command prompt.

  • Type python and hit enter to turn windows command prompt to python idle (make sure python is installed).

  • Type quit() and hit enter to turn it back to windows command prompt.

  • Type cls and hit enter to clear the command prompt/ windows shell.

查看更多
仙女界的扛把子
6楼-- · 2019-01-04 17:40

If you want to clear the shell buffer go to shell > restart shell in IDLE. Your question is a little vague. Do you want to clear the shell buffer or are you trying to call the OS command?

查看更多
看我几分像从前
7楼-- · 2019-01-04 17:40

use this

for num in range(1,100):
    print("\n")
查看更多
登录 后发表回答