本文介绍了Python 2.7的Shebang行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Linux Centos中安装了Python2.7,并且默认安装了Python2.6,

I have installed Python2.7 in my Linux Centos which comes with a default Python2.6 installation,

默认Python

[root@linuxhost PythonProjects]# python -V
Python 2.6.6

默认Python2.7

Default Python2.7

[root@linuxhost PythonProjects]# python2.7 -V
Python 2.7.3

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

Now I need to write programs based on python2.7 version...What would be the shebang line for python2.7

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

Also, how will I compile using python2.7.

推荐答案

Shebang将是:

Shebang will be:

#!/usr/bin/env python2.7

我不确定为什么要编译Python文件(导入时Python会自动执行).

I'm not sure why you want to compile Python files (Python will do it automatically when you import them).

如果您确实要:

python2.7 -m compileall .

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

This command will compile .py files in the current directory to .pyc:

这篇关于Python 2.7的Shebang行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 15:00