How do you see the entire command history in interactive Python?

后端 未结 10 1811
不知归路
不知归路 2020-11-30 16:36

I\'m working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow

10条回答
  •  执念已碎
    2020-11-30 17:09

    If you want to write the history to a file:

    import readline
    readline.write_history_file('python_history.txt')
    

    The help function gives:

    Help on built-in function write_history_file in module readline:
    
    write_history_file(...)
        write_history_file([filename]) -> None
        Save a readline history file.
        The default filename is ~/.history.
    

提交回复
热议问题