简体   繁体   中英

python don't save files in visual studio code

I started to use visual studio code yesterday and i'm having this problem...

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.

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:

{
    "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.

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
        }
    ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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