- Python Programming with Raspberry Pi
- Sai Yamanoor Srihari Yamanoor
- 136字
- 2021-07-02 23:48:42
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.
- On the Linux Terminal, switch to the directory where the Python script is located:
cd /home/pi/Desktop/code_samples
- Execute the Python script as follows:
python3 helloworld.py
- 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.
推薦閱讀
- Clojure Data Analysis Cookbook
- 機艙監測與主機遙控
- 深度學習中的圖像分類與對抗技術
- Arduino &樂高創意機器人制作教程
- 云原生架構進階實戰
- 網絡布線與小型局域網搭建
- Machine Learning with Apache Spark Quick Start Guide
- 網站入侵與腳本攻防修煉
- Microsoft System Center Confi guration Manager
- FPGA/CPLD應用技術(Verilog語言版)
- Advanced Deep Learning with Keras
- 分布式Java應用
- 工業機器人基礎
- 互聯網單元測試及實踐
- 智能機器人創新熱點與趨勢