Here’s what we saved in our python_script.py for i in range(0,5): print(i)Īnd, the output on your command line looks something like this Replace python3 with python if your Python version is Python2.x. To execute your Python script(python_script.py) open command line and write python3 python_script.py Make sure you specify the path to the script or have the same working directory. Python scripts can be run using Python command over a command line interface. #RUNNING PYTHON ON MAC HOW TO#How to run Python scripts using command line? Now, you can write a Python code here and easily run it using command line. Once you hit enter, you’ll get into a command line interface that looks something like this: Once you are in the right directory, execute the following command in Terminal: $ sudo nano python_script.py Basically as simple as saving a text file.īut, to do it via Command line, there are a couple of steps involved.įirst, head to your command line, and change your working directory to where you wish to save the Python script. Saving a Python script from a code editor is pretty easy.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |