0 votes
1 view
in Python by (31.4k points)

Just a quick question:

How do you clear the screen in the shell? I've seen ways like:

import os os.system('cls')

This just opens the windows cmd, clears the screen and closes but I want the shell window to be cleared

(PS: I don't know this helps, but I'm using version 3.3.2 of Python)

Thank you :)

1 Answer

0 votes
by (73.5k points)
edited by

For clearing screen in the shell for OS X, you can use the subprocess module and call 'cls' from the shell:-

import subprocess as sp sp.call('cls',shell=True)

For the window you can use the following:-

tmp = sp.call('cls',shell=True)

For Linux, you must replace cls command with clear

tmp = sp.call('clear',shell=True)

To know more about this you can have a look at the following video tutorial:-

...