简体   繁体   中英

Visual Studio Code executes file only from Ctrl+F5

Can anyone explain why Visual Studio Code don't execute some files from this button ? Only Ctrl+5 works. When i am runnug code from button it gaves me "invalid syntax" ?

Reason: This is because the current VSCode terminal is a Python interactive window, it will execute correctly when you enter a python statement, but the command to click the run button is similar to" D:/Users/.../AppData/Local/ Programs/Python/Python39/python.exe d:/.../test09/a.py ", it is not a python statement, so the console returns " SyntaxError ".

The reason you can use " Ctrl+F5 " or " F5 " to execute code is that this is a debugging process and it will run in the "Python Debug console" terminal.

Solution: Enter the statement " exit() " in the console to exit the Python interactive window.

在此处输入图片说明

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