Possible Duplicate:
Why do people write #!/usr/bin/env python on the first line of a Python script?
What does the line “#!/bin/sh” mean in a UNIX shell script?
这是一个注释,解释器应该忽略它。为什么 #!/usr/bin/python 仍然在几乎每个程序中?
最佳答案
如果脚本是可执行的,操作系统将使用第一行来了解哪个解释器运行来解析文件的其余部分以执行一些操作。
如果您总是从命令行运行这些类型的脚本,例如 python foo.py
,那么您可以删除第一行。
关于python - '#!/usr/bin/python' 在每个 Python 脚本前面是必须的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9900949/