How to log everything that occurs in a Python interactive shell session?

后端 未结 5 1466
小蘑菇
小蘑菇 2021-01-05 09:23

I\'d like to have real-time access to both interpreter input and error and standard output. Preferably this information would be written to a file, so that I can poll the fi

5条回答
  •  情话喂你
    2021-01-05 09:56

    You can simply use the unix script command, try:

    script -a filename.txt
    python
    >> print("hi")
    hi
    >> exit()
    exit
    

    filename.txt will record everything you did on that session, it will look something like this:

    Script started on Sat Dec 14 11:18:41 2013
    python
    >> print('hi')
    hi
    >> exit()
    exit
    
    Script done on Sat Dec 14 11:18:59 2013
    

提交回复
热议问题