1
我想永遠記錄ipython命令行並輸出到附加模式的文件。對下.ipython/profile_default/startup
自述ipyton啓動腳本語法錯誤
$ cat README
This is the IPython startup directory
.py and .ipy files in this directory will be run *prior* to any code or files specified
via the exec_lines or exec_files configurables whenever you load this profile.
Files will be run in lexicographical order, so you can control the execution order of files
with a prefix, e.g.::
00-first.py
50-middle.py
99-last.ipy
讀取文件我嘗試添加一個文件first.py下面內容
logstart -o -r -t logs/ipython.log 'append'
logstart
是一個神奇的命令。當我嘗試啓動ipython時出現以下錯誤
File "/home/mtk/.ipython/profile_default/startup/00-first.py", line 1
logstart -o -r -t logs/ipython.log 'append'
^
SyntaxError: invalid syntax
如何解決此問題?
要在啓動文件中使用魔術命令,請使用'.ipy'擴展名。 '.py'文件必須是常規的Python代碼,不需要IPython特殊的語法。 –