How to clear Python shellSometimes working with the Python shell, we got haphazard output or wrote unnecessary statements, and we want to clear the screen for some other reason. The "cls" and "clear" commands are used to clear a terminal (terminal window). If, you are using the shell within IDLE, which won't be affected by such things. Unfortunately, there is no way to clear the screen in IDLE. The best you could do is to scroll the screen down lots of lines. For example - Though you could put this in a function: And then call it when needed as cls() function. It will clear the console; all previous command will be vanished and screen start from the beginning. If you are using a Linux, then - If you're using Windows- We can also do it using the Python script. Consider the following example. Example - Note - An underscore variable is used because Python shell always stores its last output in the underscore.Next TopicHow to create a DataFrames in Python |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India