Python file types

Source: Internet
Author: User

/*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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.