Shebang系列为Python 2.7

use*_*619 12 python linux

我在我的Linux Centos中安装了Python2.7,它安装了默认的Python2.6,

默认Python

[root@linuxhost PythonProjects]# python -V
Python 2.6.6
Run Code Online (Sandbox Code Playgroud)

默认Python2.7

[root@linuxhost PythonProjects]# python2.7 -V
Python 2.7.3
Run Code Online (Sandbox Code Playgroud)

现在我需要编写基于python2.7版本的程序...... python2.7的shebang行是什么

另外,我将如何使用python2.7进行编译.

Nig*_*nel 19

Shebang将是:

#!/usr/bin/env python2.7
Run Code Online (Sandbox Code Playgroud)

我不确定你为什么要编译Python文件(Python会在你导入它们时自动完成).

如果你真的想:

python2.7 -m compileall .
Run Code Online (Sandbox Code Playgroud)

此命令将当前目录中的.py文件编译为.pyc: