Logging input and output in Spyder's console

ε祈祈猫儿з 提交于 2019-11-28 10:23:32

问题


I learnt data manipulation and analysis through Stata and I used the log command to record all the commands written and the output generated. Doing so I could reproduce my findings, check previous results and share it with others in pdf or txt. What to use with Python? Is there a difference if I use a Python Jupyter Notebook or Spyder?


回答1:


The way to do what you want is by using the %logstart command, as described here:

Log IPython output?




回答2:


Stop using the python interpreter and start storing your commands in a text file before running them. This way you will be able to share, reuse, and revise your python code.

By executing the following command:

python code.txt

Python will read all of the lines in your file sequentially.

This is the main way python programs are executed, as a convention, python code files end with .py , so if you see a file with a .py extension, you can try executing it yourself using this method!



来源:https://stackoverflow.com/questions/53532655/logging-input-and-output-in-spyders-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!