Clear screen command in python



In windows commnad line we use "cls" to clear screen. 
But there is no strait forward command to clear console screen in python. 
To have command like that we need to import "OS" module. Let us see how to do so,

Go to Python Command Line :

>>>import os
>>>cls = lambda: os.system('cls')
>>>cls()

Now it is registered with python. Now lets see how to use it in pythong window.

>>> # clear screen demo
.....  print("dotnetqueries")
dotnetqueries
>>> cls()
>>> # this will clear screen

Here, you can use this command until open window session is alive.
That means once you close the window and reopen it this command will not work.
Again you need to register it to use.

Labels: Clear screen command in python, cls() in python, cls in python, clear screen in python



Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker