有没有一种方法可以在我的IPython提示符中获取本地时间戳?我正在使用IPython 0.10和Python 2.6在64位Windows Vista上。
我的当前默认提示符是:
并且我拿到了这个作为例子:
我的当前默认提示符是:
[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]:
问题:
- What is that
1
? How can I keep the current directory in the prompt? Before, I had
[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'[\#] '
# -- 提示符 # 一组不同的、更紧凑的提示符,总是显示您当前在文件系统中的位置: 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'[\#] ' o.prompt_in1 = r'${datetime.now().strftime("%H:%M:%S")} In[\#]: '
- NotSuper