且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

运行python脚本和#!/ usr / bin / python行

更新时间:2023-01-14 22:41:34

/ usr / local / pyscripts必须在您可以在.bashrc文件中设置的路径。

将执行python脚本的shebang thells。所以你可以使用python 3使用python,使用python 2.7使用另一个python。在Arch Linux上很常见,也可能是其他人。
/usr/local/pyscripts must be in your path which you can set in your .bashrc file.
The shebang thells which python your script will be executed with. So you could have python using python 3 and another one using python 2.7. Very common on Arch Linux, probably others too.


事实证明,只有在开发过程中运行时,shebang才有用。考虑到它的2个要求,简单地使用命令行就更直接了:
As it turns out, the shebang is somewhat useful only when running during development. Considering its 2 requirements it is far more direct to simply use the command line like :


python myapp.py


shebang line对于尝试运行myapp.py只是无用的:
python myapp.py

The shebang line is useless for trying to run myapp.py giving only :