有没有办法在我的 IPython 提示符中获取本地时间戳?我在 64 位 Windows Vista 上使用 IPython 0.10 和 Python 2.6。
我当前的默认提示是
[C:Python26/Scripts]
|9>
好的,我试着完全按照你的指示去做。但是,我的经验是所有配置编辑最好保存在我的ipy_user_conf.py
. 引用它:
User configuration file for IPython (ipy_user_conf.py)
This is a more flexible and safe way to configure ipython than *rc files
(ipythonrc, ipythonrc-pysh etc.)
This file is always imported on ipython startup. You can import the
ipython extensions you need here (see IPython/Extensions directory).
Feel free to edit this file to customize your ipython experience.
Note that as such this file does nothing, for backwards compatibility.
Consult e.g. file 'ipy_profile_sh.py' for an example of the things
you can do here.
See http://ipython.scipy.org/moin/IpythonExtensionApi for detailed
description on what you could do here.
所以我现在在 main() 中有这些行:
# -- prompt
# A different, more compact set of prompts from the default ones, that
# always show your current location in the filesystem:
o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>'
o.prompt_in2 = r'.\D: '
o.prompt_out = r'[\#] '
我得到了这个,例如:
16:49:50 In[9]:1/7
1 [9] 0.14285714285714285
16:50:09 In[10]:
问题:
- 那是什么
1
? 如何将当前目录保留在提示符中?之前,我有
[C:Python26/Scripts] |8>
再一次带着感觉。我为自己造成的混乱感到非常抱歉。我需要报告我实际添加或修改的行是:
import_all("os sys random datetime")
o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>'
o.prompt_in1 = r'${datetime.now().strftime("%H:%M:%S")}[\#]:'
o.prompt_out = r'[\#] '