How to clear the interpreter console?

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

    Well, here's a quick hack:

    >>> clear = "\n" * 100
    >>> print clear
    >>> ...do some other stuff...
    >>> print clear
    

    Or to save some typing, put this file in your python search path:

    # wiper.py
    class Wipe(object):
        def __repr__(self):
            return '\n'*1000
    
    wipe = Wipe()
    

    Then you can do this from the interpreter all you like :)

    >>> from wiper import wipe
    >>> wipe
    >>> wipe
    >>> wipe
    

提交回复
热议问题