pythonterminal

Clear the terminal in Python


Does any standard "comes with batteries" method exist to clear the terminal screen programatically from a Python script, or do I have to use curses (the libraries, not the words)?


Solution

  • Use escape sequences:

    print(chr(27) + "[2J")