[Python] Execute a Python Script


Python scripts can be executed by passing the script name to the python command or created as executable commands that can run stand-alone. You’ll learn how to create both in this lesson.

 

script.py:

print("Hello World")

 

When we want to run the script, we can do:

python3 script.py

 

We can also make the script a stand-alone executable:

#! /usr/bin/env python

print("Hello World")
chmod +x script.py
./script.py

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM