2024-04-24 17:22:57 发布
网友
有没有办法在IPython提示符中显示当前目录?
Instead of this: In [1]: Something like this: In<~/user/src/proj1>[1]:
https://ipython.org/ipython-doc/3/config/details.html#specific-config-details
In the terminal, the format of the input and output prompts can be customised. This does not currently affect other frontends.
因此,在.ipython/profile_default/ipython_config.py中,输入如下内容: c.PromptManager.in_template = "In<{cwd} >>>"
c.PromptManager.in_template = "In<{cwd} >>>"
使用!在pwd显示当前目录之前
In[1]: !pwd /User/home/
当交互计算时,通常需要访问底层shell。这是可以通过使用感叹号!(或砰)在一行开始时执行一个命令。
您可以使用os.getcwd(当前工作目录)或本机操作系统命令pwd。
os.getcwd
pwd
In [8]: import os In [9]: os.getcwd() Out[9]: '/home/rockwool' In [10]: pwd Out[10]: '/home/rockwool'
https://ipython.org/ipython-doc/3/config/details.html#specific-config-details
因此,在.ipython/profile_default/ipython_config.py中,输入如下内容:
c.PromptManager.in_template = "In<{cwd} >>>"
使用!在pwd显示当前目录之前
当交互计算时,通常需要访问底层shell。这是可以通过使用感叹号!(或砰)在一行开始时执行一个命令。
您可以使用
os.getcwd
(当前工作目录)或本机操作系统命令pwd
。相关问题 更多 >
编程相关推荐