繁体   English   中英

python 不在 Visual Studio 代码中保存文件

[英]python don't save files in visual studio code

我昨天开始使用 Visual Studio 代码,但我遇到了这个问题......

假设我有这个代码:

myFile = open("file.txt", "w+")
myFile.write("something \n")
myFile.close()

当我在 VScode 上运行它时,它不会保存文件,但是当我在 SublimeText 中运行它时它会保存。

你知道如何解决吗? 我没有找到任何东西(或者我不知道如何搜索),我的 launch.json 看起来像这样:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "internalConsole"
        }
    ]
}

**在我写完之后,我注意到它将文件保存在“C:\Users\User\Documents\vsprofiles”中,但是我的桌面上有 my.py 文件,我希望它将文件保存在相同的路径中.py 文件就像 SublimeText 一样。

为了完整起见,这是我的配置文件

"launch": {
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "${fileDirname}",
            "env": {},
            "pythonArgs": [],
            "stopOnEntry": false
        }
    ]
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM