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

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.

主站蜘蛛池模板: 林周县| 论坛| 凤冈县| 东港市| 绍兴县| 西丰县| 保德县| 贵阳市| 商都县| 福泉市| 奉贤区| 桦南县| 固原市| 汤阴县| 博野县| 西乌| 湘阴县| 车险| 新安县| 昌江| 若尔盖县| 临海市| 松潘县| 勐海县| 陆良县| 资溪县| 沙坪坝区| 隆尧县| 永泰县| 潢川县| 安吉县| 偃师市| 临海市| 甘南县| 安庆市| 禹州市| 巧家县| 兰州市| 嘉义县| 新昌县| 和静县|