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

查看:43
本文介绍了从 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:Python27Python.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:Python27Python.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:Python27Python.exe myscript.py")

避免设置环境变量.

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

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