How to clear the interpreter console?

后端 未结 30 2202
自闭症患者
自闭症患者 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:36

    As you mentioned, you can do a system call:

    For Windows

    >>> import os
    >>> clear = lambda: os.system('cls')
    >>> clear()
    

    For Linux the lambda becomes

    >>> clear = lambda: os.system('clear')
    

提交回复
热议问题