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

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.

主站蜘蛛池模板: 金沙县| 读书| 长岭县| 高阳县| 南丰县| 施甸县| 潞西市| 汉中市| 略阳县| 新津县| 邵阳县| 浦城县| 四子王旗| 深水埗区| 六枝特区| 肃南| 玉林市| 肥城市| 汕头市| 咸丰县| 兴和县| 马公市| 五指山市| 江山市| 白河县| 岑溪市| 北安市| 湄潭县| 宁都县| 容城县| 凤台县| 新乐市| 襄樊市| 逊克县| 花莲县| 额济纳旗| 汪清县| 西平县| 茂名市| 民权县| 施秉县|