Python - Clearing the terminal screen more elegantly
问题 I know you can clear the shell by executing clear using os.system , but this way seems quite messy to me since the commands are logged in the history and are litterally interpreted as commands run as the user to the OS. I'd like to know if there is a better way to clear the output in a commandline script? 回答1: print "\033c" works on my system. You could also cache the clear-screen escape sequence produced by clear command: import subprocess clear_screen_seq = subprocess.check_output('clear')