Run with command line parameters in PyCharm.
When we develop Python program in PyCharm, sometimes we would like to run it woth parameters.
This article shows how to run with parameters in PyCharm.
Precondition
About PyCharm, please check past article.
-
We can't input text in PyCharm
And you can see how to run python code with command line parameters below.
-
Get parameter from command line in Python (sys.argv)
Advantage of running with parameters in PyCharm
Why do we want to run Python with parameters in PyHarm ?
It is because of debug.
When we use PyCharm, we write Python code on PyCharm.
And we check its action on PyCharm.
In case of making batch files, they would be checked with different parameters.
But PyCharm is GUI editor, so we can't run like python (file name) parameter
.
Then we have to know how to set parameters in GUI.
how to run with parameters in PyCharm.
In order to run with parameters, settings is required in PyCharm.
Settings is like below.
If you set parameters in Parameters
, you can execute it when you push Run
.
[code lang=text]
Manu bar → Run → Edit Configurations → Parameters
[/code]
PyCharm settings
PyCharm command line settings
Finally
- It is useful for debug to to run with parameters in PyCharm.
- You can do settings in manu bar
Run → Edit Configurations
.