Python 使用 PyCharm 终端参数进行调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27952331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Debugging with PyCharm terminal arguments
提问by Liondancer
I have been using PyCharm for a bit so I am not an expert.
我一直在使用 PyCharm,所以我不是专家。
How I normally ran my programs was with the terminal like so:
我通常如何在终端上运行我的程序,如下所示:
program.py -t input1 -t1 input2
program.py -t input1 -t1 input2
I was wondering how can I debug this?
我想知道如何调试这个?
For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.
对于我编写的其他程序,我没有任何参数,因此调试只是设置断点并按调试。
采纳答案by Andrew_Lvov
Menu: Run
-> Edit configurations
-> "+" (add new config)
-> Python
.
菜单:Run
-> Edit configurations
-> "+" (add new config)
-> Python
。
Script name: program.py
脚本名称: program.py
If you need to debug a script from installed packages, such as tox
, you can specify the full path too. For example:
Script name: /home/your_user/.envs/env_name/bin/tox
如果您需要从已安装的包中调试脚本,例如tox
,您也可以指定完整路径。例如: 脚本名称:/home/your_user/.envs/env_name/bin/tox
Above /home/your_user/.envs/env_name
is a path to virtual environment containing tox
package.
以上/home/your_user/.envs/env_name
是包含tox
包的虚拟环境的路径。
Script params: -t input1 -t1 input2
脚本参数: -t input1 -t1 input2
回答by ArjunM
It was almost correct but just needed little correction with full script path.
它几乎是正确的,但只需要对完整的脚本路径进行少量更正。
Menu: Run->Edit configurations->"+" (add new config)->Python
.
菜单:Run->Edit configurations->"+" (add new config)->Python
。
Script name: path + /program.py
脚本名称: path + /program.py
Script params: -t input1 -t1 input2
脚本参数: -t input1 -t1 input2
回答by Jebaseelan Ravi
Just the image wise representation of answer
只是答案的图像明智表示
step 1: Click on the Run
menu click Edit configuration
第一步:点击Run
菜单点击Edit configuration
- Select
+
in top right corner and selectpython
- 选择
+
在右上角选择python
- Provide the
name
,absolutepath of the script/ select the script by clicking three dots(green marker
,script paramters
andpython interpreter
- 提供
name
,absolutepath of the script/ select the script by clicking three dots(green marker
,script paramters
和python interpreter