简体   繁体   中英

Different behavior when using Debug/Run button and F5/Ctrl+F5 in Visual Studio Code (Python)

I am trying to pass an argument to a python script and I'm using a standard "Python file" debug configuration with the "launch.json" file for this purpose. I have defined the argument in my debug configuration ( "args": ["car"] )and started to run the script with F5. It is working. The application has access to the passed argument.

However, if i try to CLICK on the "Run Python File" button in the upper right corner of my editor the script crashes because of no argument was passed to it.

Same goes for "Debug Python File"-Button and Ctrl+F5. Ctrl+F5 works, clicking the button does not.

What is the issue here?

The code I am trying to run with a passed argument:

https://github.com/RGGH/ebay_api_postgres/blob/main/ebay_21.py

"Run Python FIle" and "Debug Python File" don't run the "project", so they don't grab the argument from the project configuration. Use F5 and Ctrl-F5, or run in the terminal.

Yes, it is. Like Tim Roberts's explanation, you can get the executed commands in the terminal, you will find Run Python FIle and Debug Python File will not invoke the arguments you defined in the launch.json except you take F5 or Ctrl+F5 . They just run the python file.

And of course, you can run the python file in the terminal directly and adds the arguments manually.

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