9
有什麼辦法可以讓IPython的日誌功能包括輸出和輸入?登錄IPython輸出?
這是一個日誌文件看起來像目前:
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
我想有一個多行顯示:
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
# test
(該#
,是因爲我認爲需要以防止突破IPython的logplay
功能)
我想這是可能的使用IPython筆記本電腦,但至少有一臺機器我需要這個,我的限制編輯ipython 0.10.2。
編輯:我想知道如何自動設置,即在配置文件中。現在我的配置看起來像
from time import strftime
import os
logfilename = strftime('ipython_log_%Y-%m-%d')+".py"
logfilepath = "%s/%s" % (os.getcwd(),logfilename)
file_handle = open(logfilepath,'a')
file_handle.write('########################################################\n')
out_str = '# Started Logging At: '+ strftime('%Y-%m-%d %H:%M:%S\n')
file_handle.write(out_str)
file_handle.write('########################################################\n')
file_handle.close()
c.TerminalInteractiveShell.logappend = logfilepath
c.TerminalInteractiveShell.logstart = True
但指定c.TerminalInteractiveShell.log_output = True
似乎也沒有影響
該解決方案似乎是在啓動腳本中執行此操作,如下所述:http://wiki.ipython.org/Cookbook/DatedLog(這是http://stackoverflow.com/questions/11836612中提供的解決方案/其中-如何合什麼-上下文是-ipythons配置文件執行的?LQ = 1) – keflavich 2012-08-15 15:46:40