官术网_书友最值得收藏!

Executing Python scripts using the Linux Terminal

It is possible to execute code written using any text editor via the Linux Terminal. For example, Let's say the file helloworld.py is saved in a folder named code_samples on the Raspberry Pi's desktop. This file may be executed as follows from the Linux Terminal:

If you are not familiar with the Linux command-line terminal, we have written up some tutorials to familiarize yourself with the command-line terminal on this book's website.

  1. On the Linux Terminal, switch to the directory where the Python script is located:
       cd /home/pi/Desktop/code_samples
  1. Execute the Python script as follows:
       python3 helloworld.py
  1. Alternatively, the Python script could be executed using its absolute location path:
       python3 /home/pi/Desktop/code_samples/hello_world.py

We did it! We just wrote our first piece of code and discussed different ways to execute the code.

主站蜘蛛池模板: 平塘县| 洛阳市| 同心县| 班戈县| 张掖市| 宁津县| 民权县| 宜君县| 武汉市| 河西区| 西华县| 昌江| 和田县| 富锦市| 武隆县| 山西省| 邢台市| 铁岭县| 红安县| 大英县| 通许县| 招远市| 福泉市| 香河县| 璧山县| 肇东市| 南召县| 封丘县| 武汉市| 永德县| 肇源县| 大关县| 鄂托克前旗| 萨迦县| 河东区| 汪清县| 方城县| 黄骅市| 贵南县| 桦南县| 石屏县|