简体   繁体   English

Ahk:使用 args 运行 python 脚本

[英]Ahk: run a python script with args

I have seen this thread (and many others) but I am still not able to retrieve the args in python.我已经看到了这个线程(以及许多其他线程),但我仍然无法在 python 中检索参数。

1) With this... 1)有了这个...

Run Cmd \k "Python  C:\my.py %myvar%"

... a Cmd is open but nothing happens : my.py isn't started. ... Cmd 已打开但没有任何反应:my.py 未启动。

2) With this... 2)有了这个...

Run C:\my1.py %myvar% 

... the python script is run but when I retrieve the args with sys.argv , I only get the path of the script not myvar . ... python 脚本正在运行,但是当我使用sys.argv检索 args 时,我只得到脚本的路径而不是myvar Len(sys.arg) return 1 so myvar isn't passed down to python. Len(sys.arg) 返回 1,因此 myvar 不会传递给 python。

This thread solved it.这个线程解决了它。

commands=
(join&
 python "C:\my.py" "%myvar%"`n
)
Run, cmd /c %commands%  
return

It's also possible to use Run, cmd /k %commands% or Run,%comspec% /k %commands%也可以使用Run, cmd /k %commands%Run,%comspec% /k %commands%

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM