【发布时间】:2014-05-19 09:47:37
【问题描述】:
我无法更改 IPython 中的当前工作目录,我不知道为什么。
在下面的示例中,我从 C 驱动器的根目录启动 IPython,并尝试以多种方式更改当前工作目录。奇怪的事情结果:
C:\>ipython
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: cd
C:\Users\jkokorian
In [2]: %cd "C:\Dell"
C:\Dell
In [3]: cd
C:\Users\jkokorian
In [4]: import os
In [5]: os.chdir("C:\Dell")
In [6]: os.getcwd()
Out[6]: 'C:\\Dell'
In [7]: cd
C:\Users\jkokorian
In [8]: os.getcwd()
Out[8]: 'C:\\Users\\jkokorian'
不知何故,工作目录总是默认为我的主文件夹,即使 IPython 从 C: 的根目录启动。
有人知道这里发生了什么吗?
【问题讨论】: