问题描述
我有一个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脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!