在VSCODE Python中更改工作目录的问题
一直在尝试更改VSCODE中的工作目录。 我的环境是基本的Anaconda环境。
import os
os.getcwd()
>>> '/Users/hh'
然后,我将其更改为,
os.chdir('/Users/hh/pywd/')
os.getcwd()
>>> '/Users/hh/pywd/'
但是当我关闭时,重新启动VSCODE并运行
import os
os.getcwd()
## I get the output below yet again
>>> '/Users/hh'
WD设置为先前的状态。
这很好奇,因为我与Spyder或Jupyterlab没有同样的问题。
感谢您的帮助。
Been trying to change my working directory in VScode.
My environment is the base Anaconda environment.
import os
os.getcwd()
>>> '/Users/hh'
I then change it to
os.chdir('/Users/hh/pywd/')
os.getcwd()
>>> '/Users/hh/pywd/'
But when I close down, restart VScode and run
import os
os.getcwd()
## I get the output below yet again
>>> '/Users/hh'
The wd is set to its previous state.
This is rather curious as I don't have the same issue with Spyder or JupyterLab.
Thankful for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VSCODE的路径基于工作区所在的目录。
关闭VSCODE时,它将自动返回工作区目录,而不是在上次运行结束时呆在州。
尽管您目前还还原代码,但您将无法获得最后一次运行的结果。
这也是有益的,可以确保在搜索路径时不会混淆VScode。
The path of vscode is based on the directory where the workspace is located.
When you close vscode , it will automatically return to the workspace directory instead of staying in the state at the end of the last run.
Although you restore the code at this time, you will not get the result of the last run.
This is also beneficial, which can ensure that the vscode will not be confused when searching path.