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条回答
SAY GOODBYE
2楼-- · 2019-01-04 17:41

An extension for clearing the shell can be found in Issue6143 as a "feature request". This extension is included with IdleX.

查看更多
Evening l夕情丶
3楼-- · 2019-01-04 17:41

I would recommend you to use Thonny IDE for Python. It's shell has "Clear Shell" option and you can also track variables created in a separate list. It's debugging is very good even comparing with modern IDEs. You can also write code in python file along with access to shell at the same place.

And its lightweight!

查看更多
叛逆
4楼-- · 2019-01-04 17:42

ctrl + L clears the screen on Ubuntu Linux.

查看更多
Explosion°爆炸
5楼-- · 2019-01-04 17:42

This works for me in Windows:

print chr(12)

查看更多
▲ chillily
6楼-- · 2019-01-04 17:43

The best way to do it on windows is using the command prompt 'cmd' and access python directory the command prompt could be found on the start menu >run>cmd

C:\>cd Python27
C:\Python27>python.exe
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>import os
>>>os.system('cls')  #This will clear the screen and return the value 0
查看更多
Summer. ? 凉城
7楼-- · 2019-01-04 17:45

File -> New Window

In the new window**

Run -> Python Shell

The problem with this method is that it will clear all the things you defined, such as variables.

Alternatively, you should just use command prompt.

open up command prompt

type "cd c:\python27"

type "python example.py" , you have to edit this using IDLE when it's not in interactive mode. If you're in python shell, file -> new window.

Note that the example.py needs to be in the same directory as C:\python27, or whatever directory you have python installed.

Then from here, you just press the UP arrow key on your keyboard. You just edit example.py, use CTRL + S, then go back to command prompt, press the UP arrow key, hit enter.

If the command prompt gets too crowded, just type "clr"

The "clr" command only works with command prompt, it will not work with IDLE.

查看更多
登录 后发表回答