简体   繁体   English

每次在pyCharm中以不同的参数运行py文件

[英]Run py file with different arguments each time in pyCharm

I have some script : run.py , I was using it in terminal like : 我有一些脚本: run.py ,我在终端中使用它,例如:

python run.py -t 10 -s adidas -f mozilla
python run.py -t 2 -s nike -f chrome
python run.py -t 100 -s puma -f safari
python run.py -t 1 -s tom

but how to live in pyCharm? 但是如何生活在pyCharm中呢? I need each time to configure Run/Debug configuration ? 我每次都需要配置运行/调试配置吗? Thanx 感谢名单

easiest is to make a runner file 最简单的方法是制作跑步者文件

testrunner.py (same folder as run.py) testrunner.py (与run.py相同的文件夹)

import .run
args= [ "-t 10 -s adidas -f mozilla","-t 2 -s nike -f chrome","-t 100 -s puma -f safari"]
for arg in args:
    sys.argv[1:] = arg.split()
    reload(run)
    run.main()        

or you can use os.system to call it with the arguments, but you lose alot of the debugging features of pycharm doing that ... 或者您可以使用os.system通过参数调用它,但是这样做会丢失pycharm的许多调试功能...

or alternatively you could make 1 run config for each set of paramaters and save the run config(this is probably how pycharm expects you to do it) 或者,您可以为每组参数设置1个运行配置并保存运行配置(这可能是pycharm期望您执行的操作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyCharm - 每次保存文件时运行相应的单元测试 - PyCharm - run a corresponding unit test each time a file is saved 如何使用不同的 py 文件运行需要 arguments 的不同 py 文件夹? - How can I run a different py folder that requires arguments using a different py file? 为什么 pycharm 上的文件 (.py) 运行的文件与当前运行的文件不同? - Why does a file (.py) on pycharm run a different file than the one that’s currently on? 如何删除PyCharm中已删除的py文件的运行配置文件? - How to delete run configuration file for a py file that was already deleted in PyCharm? 当我从批处理文件运行 .py 文件时打开 PyCharm - PyCharm opening when I run .py file from batch file Py2 - 使用 Arguments 运行 Bash 脚本 - 将 Output 存储在不同目录中的文件中 - Py2 - Run Bash Script with Arguments - Store Output in a file in a different directory 如何在完全不同的项目中从 .py 文件运行 .py 文件 - How to run a .py file from a .py file in an entirely different project 同时运行多个.py python文件 - Run multiple .py python file at the same time 多次运行 function,每次运行使用不同的 arguments - Run a function multiple times with different arguments for each run 将 pycharm 中的.py 文件转换为 .ipynb 文件 - Convert .py to .ipynb file in pycharm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM