One, Python file types

Source: Internet
Author: User

Python File types:


1. Source code file: with "py" as extension, interpreted by Python program


(a)
# Cat test1.py
print "Hello world!"
# python test1.py
Hello world!
(b)
# Cat test1.py
#!/usr/bin/python (this line specifies to be interpreted in Python language)
print "Hello world!"
# chmod +x test1.py
#./test1.py
Hello world!


2. Byte code file: compiled to generate a file with the extension "PYc" (binary file)


Compilation Method--Import Py_compile
Py_compile.compile ("test1.py")
(a)
# Cat test2.py
Import Py_compile
Py_compile.compile ("test1.py")
# python test2.py
# ls
test1.py Test1.pyc test2.py

3. Optimized code files: optimized source files with the extension ". Pyo" (binary file)


# Python-o-M Py_compile test1.py
# ls
test1.py TEST1.PYC test1.pyo test2.py


This article from "Meteor Yu" blog, declined reproduced!

One, Python file types

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.