我正在尝试启动可能带有txt文件(config.txt)中列出的一些参数的主Python脚本。
因为参数几乎每次启动都会更改,所以我不想每次都键入它们。它们实际上不是一个“配置”,但我没有找到正确的文件名(这是另一个故事)。
见下文:
-param1 1
-param2 2
-verbose
我最终想做的是:python C:\somewhere\main.py -param1 1 -param2 2 -verbose
代替当前行为:python C:\somewhere\main.py config.txt
顺便说一下,程序错过了(显然)。
我已经尝试过Windows for
在“启动前:激活工具”:
$: for /f "delims=" %x in (config.txt) do set ARGS=%ARGS%%x
$: python C:\somewhere\main.py %ARGS%
但是它仅将config.txt
的最后一行保留在ARGS
内。
我还试图将文件内容通过管道传递到我的python主程序中,例如:
python C:\somewhere\main.py < config.txt
但它也不起作用。
我是对的,您想看到类似https://youtrack.jetbrains.com/issue/PY-5543的内容吗?