简体   繁体   English

如果在python脚本中未指定,则默认的shebang是什么?

[英]what is the default shebang if none is specified in a python script?

python脚本中指定了默认的shebang是none,如下所示。

print "hello world"

There is no default shebang. 没有默认的shebang。

A shebang is not Python syntax, it is a hint used by your shell on Unix (-like) systems, to find an appropriate executable to run the script with if found in the first line and the file is executable. shebang不是Python语法,它是Shell(在类似Unix(类似)的系统)上使用的提示,用于找到合适的可执行文件来运行脚本(如果在第一行中找到并且文件是可执行文件)。 If the line is missing, execution usually fails as the shell may try and execute the file as shell commands instead. 如果缺少该行,则执行通常会失败,因为外壳程序可能会尝试将文件作为外壳程序命令执行。

Some operating systems (specifically Windows) have different mechanisms in place to find the executable. 某些操作系统(尤其是Windows)具有适当的机制来查找可执行文件。 For example, they can map the filename extension to the executable. 例如,他们可以将文件扩展名映射到可执行文件。 In such cases any shebang lines are ignored. 在这种情况下,任何shebang线都会被忽略。

See Shebang (Unix) on Wikipedia, and the Python Windows FAQ for further details. 有关更多详细信息,请参见Wikipedia上的Shebang(Unix)Python Windows FAQ Python 3 has some improved Windows execution support, see Using Python on Windows ; Python 3改进了Windows执行支持,请参阅《 在Windows上使用Python》 the py launcher will actually read shebang lines in to dispatch to the right Python interpreter. py启动器实际上将读取shebang行以调度到正确的Python解释器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM