/*1. Python source file with "py" extension*/[[Email protected]~]# mkdir test1[[email protected]~]# CD test1/[email protected] test1]# VI1. PY//ADD#!/usr/bin/Pythonprint'Hello World'[[email protected] test1]# python1. Pyhello world[[email protected] test1]# ls-L Total Dosage4-rw-r--r--.1Root root theSeptember3 on: A 1. PY/*Execute permissions, you can directly execute the*/[email protected] test1]# chmod+x1. Py[[email protected] test1]# ls-L Total Dosage4-rwxr-xr-x.1Root root theSeptember3 on: A 1. Py[[email protected] test1]#./1. Pyhello World
/*2. The source code is compiled to generate a file with the extension "PYc"*/[email protected] test1]# VI2. PY//ADD#!/usr/bin/Pythonimport Py_compilepy_compile.compile ('1.py')//after execution, there is no response. But produced 1.pyc--〉 to 1.py character compilation//1.pyc-〉 Binary, unable to read[[email protected] test1]# python2. Py[[email protected] test1]# ls1. py1. PYc2. Py[[email protected] test1]# file1. PYc1. Pyc:python2.6 byte-compiled[[email protected] test1]# python1. Pychello World//If the source code is removed, the compiled file can still be executed .[Email protected] test1]# MV1. py/tmp/[[email protected] test1]# ls1. PYc2. Py[[email protected] test1]# python1. Pychello World
/*3. Optimized source file with "pyo" extension*///first move the files back .[Email protected] test1]# mv/tmp/1. Py. [[email protected] test1]# ls1. py1. PYc2. PY//Test[Email protected] test1]# Python-o-M py_compile1. Py[[email protected] test1]# ls1. py1. PYc1. pyo2. Py[[email protected] test1]# ls-L Total Dosage --rwxr-xr-x.1Root root theSeptember3 on: A 1. PY-rw-r--r--.1Root root theSeptember3 on: - 1. PYc-rw-r--r--.1Root root theSeptember3 on: + 1. Pyo-rw-r--r--.1Root root $September3 on: - 2. Py[[email protected] test1]# python1. Pyohello World
/**/
Python file types