There are 2 methods
1. Short Key: Under Linux/UNIX system (on x86 at least) you can use the CTRL+L
2. Writing a code:
import os if os.name == "posix": # Unix/Linux/MacOS/BSD/etc os.system("clear") elif os.name in ("nt", "dos", "ce"): # DOS/Windows os.system("CLS")
Note that for writing a code and you know your os.
You can just "import os" then "os.system([command to clear screen for that os])".
p.s. os.system() is very useful to make python work with other command in command line mode ex. os.system("python") to call python shell in python shell.
how do you implement this in python shell? I tried every combo but it does not work
ReplyDeleteI implemented nothing special. It's just a command to let python call a function in command line. For example, in Windows command prompt, "CLS" is a command to clear screen. Then, we let to make python call it using os.system("CLS").
DeleteSo, in your case if you know the command to clear screen of your system. I think it should be work.