从AutoIt执行Python脚本 [英] Execute Python script from AutoIt

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

问题描述

我有一个Python(.py)文件,需要从AutoIt中执行它.我该怎么办?

I have a Python (.py) file and need to execute it from AutoIt. How can I do this?

推荐答案

Python脚本可以从命令行执行.对于名为myscript.py的脚本,可以通过键入以下内容来运行它(假设已安装Python):

Python scripts can be executed from command line. For a script called myscript.py, you can run it (assuming Python is installed) by typing:

python myscript.py

如果要运行myscript.py而不用添加python前缀,则将Python二进制文件(例如C:\Python27\Python.exe)的路径设置为Windows环境变量.这使AutoIt可以像执行外部程序一样执行Python脚本.参考: ShellExecute() .

If you want to run myscript.py without having to prefix it by python, then set the path to the Python binary (e.g. C:\Python27\Python.exe) as Windows environment variable. This enables AutoIt to execute the Python script as if it were an external program. Reference: ShellExecute().

ShellExecute("myscript.py")

当然指向myscript.py所在的位置.使用:

Point to where myscript.py resides of course. Use:

RunWait("C:\Python27\Python.exe myscript.py")

避免设置环境变量.

这篇关于从AutoIt执行Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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