Can Python clear a DOS screen?

Fredrik Lundh fredrik at effbot.org
Thu Jan 18 17:22:56 EST 2001


Dan Rolander wrote:
> I've got a Python script that writes to a DOS console. Is it possible to
> have the script clear the screen?

    os.system("cls")

(it's as stupid as it looks, but it works everywhere.
print "\x1a[2J" can also work, but it usually doesn't)

For better control, consider using a console driver.
here's one:

    http://effbot.org/efflib/console

Cheers /F





More information about the Python-list mailing list