[英]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.