execute python script windows code example
Example 1: run python.py file
python3 file.py
Example 2: python how to run terminal command
import os
os.system("ls -l")
Example 3: how to run python file from cmd
// To run pytho script from CMD
// type python and the name of the file. Assuming hello.py
python hello.py
Example 4: Windows 10 running python scripts from cmd
cd (path to directory)
python name.py
Example 5: python fuction execute a script site:realpython.com
>>> exec(open('hello.py').read())
'Hello World!'
Example 6: how to execute a python script
C:\Python27\python.exe C:\Users\Username\Desktop\my_python_script.py