Ahk:使用 args 运行 python 脚本 [英] Ahk: run a python script with args

查看:50
本文介绍了Ahk:使用 args 运行 python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了这个线程(以及许多其他线程),但我仍然无法在 python 中检索参数.

I have seen this thread (and many others) but I am still not able to retrieve the args in python.

1) 有了这个...

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

... Cmd 已打开但没有任何反应:my.py 未启动.

... a Cmd is open but nothing happens : my.py isn't started.

2) 有了这个...

Run C:\my1.py %myvar% 

... python 脚本运行但是当我用 sys.argv 检索参数时,我只得到脚本的路径而不是 myvar.Len(sys.arg) 返回 1,因此 myvar 不会传递给 python.

... the python script is run but when I retrieve the args with sys.argv, I only get the path of the script not myvar. Len(sys.arg) return 1 so myvar isn't passed down to python.

推荐答案

这个 thread 解决了它.

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

也可以使用 Run, cmd/k %commands%Run,%comspec%/k %commands%

这篇关于Ahk:使用 args 运行 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆