How to clear the interpreter console?

后端 未结 30 2194
自闭症患者
自闭症患者 2020-11-21 18:15

Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff

30条回答
  •  旧巷少年郎
    2020-11-21 18:46

    I'm not sure if Windows' "shell" supports this, but on Linux:

    print "\033[2J"

    https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes

    In my opinion calling cls with os is a bad idea generally. Imagine if I manage to change the cls or clear command on your system, and you run your script as admin or root.

提交回复
热议问题