为什么vscode在运行python文件之前要更改目录?

为什么vscode在运行python文件之前要更改目录?,python,visual-studio-code,Python,Visual Studio Code,我在c:\github\housing\python中有一个名为sync.py的文件。当它在我的VS代码浏览器中打开时,我按Ctrl F5来执行它。当我这样做时,我在PowerShell中看到的是: PS C:\github\housing\python> cd 'c:\github\twitter'; & 'C:\Users\azhad\Anaconda3\python.exe' 'c:\Users\azhad\.vscode\extensions\ms-python.pytho

我在
c:\github\housing\python
中有一个名为sync.py的文件。当它在我的VS代码浏览器中打开时,我按Ctrl F5来执行它。当我这样做时,我在PowerShell中看到的是:

PS C:\github\housing\python> cd 'c:\github\twitter'; & 'C:\Users\azhad\Anaconda3\python.exe' 'c:\Users\azhad\.vscode\extensions\ms-python.python-2020.9.114305\pythonFiles\lib\python\debugpy\launcher' '52870' '--' 'c:\github\housing\python\sync.py'

为什么VS代码会更改为其他目录?我注意到它似乎被推特文件夹吸引,是否有一个默认设置可以更改以防止出现这种情况?

通常,当python文件在VSCode中的终端“
powershell
”中执行时,它会在两个位置更改路径:

  • “python.terminal.executeInFileDir”:true,
    在“
    settings.json
    ”中设置

  • “cwd”:“c:\\github\\twitter”
    设置在“
    launch.json
    ”中:

  • 建议您在两个设置文件“
    settings.json
    ”和“
    launch.json
    ”中注释掉相关的终端调试设置。此外,请尝试重新加载或重新打开VSCode