In the process of learning and using Python, there is no need to deal with Python idle. But using Python idle will encounter a common and annoying question-how do I clear the screen? I see two kinds of answers in StackOverflow: 1. Enter in the shell
1 Import os2 Os.system (' CLS ')
This method works only with the Python shell in the cmd mode in the Windows system (because the CLS command is for CMD), and the Python idle directly returns a value of 0.
2. Define a CLS function, each time you use the input CLS ()
1 def CLS (): 2 print "\ n" * 100
This method is a pseudo-clear screen, just input full screen blank, the cursor is still at the bottom of the line, do not reach the purpose of the clear screen t-t
There are a lot of similar questions in the Python mailing list, but I don't see the answer. Google again, only to find the answer-for idle add a clear screen extension ClearWindow (you can see this extension in the http://bugs.python.org/issue6143 description). Below I say install the method that uses. First download clearwindow.py (click can download directly, not download can right-click Save, the format of the Py end), put this file in the Python x\lib\idlelib directory (X for your Python version), Then find config-extensions.def this file (the idle extension profile) in this directory and open it in Notepad (to prevent errors, you can copy a backup before you open it). Well, it may look dense when opened, and if you can, it is best to open it with the support of a highlighted editor like sublime text or vim. After opening config-extensions.def, add such a few words at the end of the sentence: [Clearwindow]enable=1enable_editor=0enable_shell=1[clearwindow_cfgbindings] Clear-window=<control-key-l> then save the exit and then you can. Open Python idle to see if options are more than one option clear shell window Ctrl+l If this is the case, it proves that you installed successfully, in the future to clear the screen directly ctrl+l can be, so EZ:). Later, I found a python idle--idlex with a variety of extensions, which is the integration of a variety of Python-idle extensions, including, of course, the clear window. Installation use is not cumbersome, download the next compressed package (click here to download), then unzip the run
idlex.pyYes, the shape is exactly the same as Python, but opinions can see more options. --------End Reference: Http://stackoverflow.com/questions/2084508/clear-terminal-in-python Http://stackoverflow.com/questi Ons/1432480/any-way-to-clear-pythons-idle-window http://idlex.sourceforge.net/extensions.html
Python Idle clear screen problem solving