问题
I have a Python (.py) file and need to execute it from AutoIt. How can I do this?
回答1:
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
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")
Point to where myscript.py
resides of course. Use:
RunWait("C:\Python27\Python.exe myscript.py")
to avoid setting environment variables.
回答2:
RunWait("C:\Python27\Python.exe filename.py")
this code working fine run from autoit
来源:https://stackoverflow.com/questions/13524339/execute-python-script-from-autoit