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

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.

主站蜘蛛池模板: 河北区| 定兴县| 新巴尔虎左旗| 田东县| 朝阳市| 安龙县| 麦盖提县| 会同县| 伊宁市| 岳西县| 五家渠市| 夏邑县| 页游| 浠水县| 富民县| 五峰| 轮台县| 灌云县| 舒城县| 桦甸市| 通化县| 雅安市| 庄浪县| 玛沁县| 尼勒克县| 南充市| 喜德县| 沙洋县| 大丰市| 阿勒泰市| 黔江区| 连云港市| 梁平县| 宁国市| 广河县| 道孚县| 长汀县| 平远县| 上饶市| 隆化县| 独山县|