简体   繁体   English

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

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

I started to use visual studio code yesterday and i'm having this problem...我昨天开始使用 Visual Studio 代码,但我遇到了这个问题......

Let's suppose I have this code:假设我有这个代码:

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

When I run it on VScode it don't save the file, but when I run it in SublimeText it does.当我在 VScode 上运行它时,它不会保存文件,但是当我在 SublimeText 中运行它时它会保存。

do you know how to solve it?.你知道如何解决吗? I didn't find anything (or I don't know how to search), my launch.json look like this:我没有找到任何东西(或者我不知道如何搜索),我的 launch.json 看起来像这样:

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

**After I wrote that I noticed that it saves the file in "C: \ Users \ User \ Documents \ vsprofiles", but I have my.py file on the desktop, I want it to save the file in the same path where the.py file is, like SublimeText does. **在我写完之后,我注意到它将文件保存在“C:\Users\User\Documents\vsprofiles”中,但是我的桌面上有 my.py 文件,我希望它将文件保存在相同的路径中.py 文件就像 SublimeText 一样。

For completeness here is my config file为了完整起见,这是我的配置文件

"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