0
I’m starting to study Python (version 3), doing several syntax tests using the interpreter for Windows. However, I would like to clear the commands I have already executed from the screen as the scroll bar grows. I tried typing clear
, clean
, CTRL+L
, but none of it worked.
It worked. But I found it a little verbose for a simple clear command...
– Marcell Alves
It’s true too, but it’s windows :P, I’ll try to find some alternative but I doubt there is a less verbose
– Miguel
There really isn’t. Because the executed command belongs to the interpreter, it is not native to Python, so you should use the library
os
. Also remember that Python is portable: the same code works on both Windows and Linux, or another operating system, so it’s interesting to do something likeos.system('cls' if os.name=='nt' else 'clear')
, forcls
works on Windows, whileclear
works on Linux.– Woss
I added this alternative (being linux) to the answer, obgado @Andersoncarloswoss
– Miguel