Linux Environment
-The Python environment is installed by default for most Linux distributions.
-Enter Python to launch Python interactive mode
-Recommended use of VIM for program editors
Windows environment
-Download the MSI package to install Python directly
-A GUI development environment that comes with Python
-Many development tools
# Linux Interactive interface [[email protected] ~]# Pythonpython 2.6.6 (r266:84292, Jan, 09:37:14) [GCC 4.4.7 20120313 (Red Hat 4.4.7 -4)] on Linux2type ' help ', ' copyright ', ' credits ' or ' license ' for more information.# exit instruction >>>exit () [[Email Protec Ted] ~]## text mode [[email protected] ~]# vim 1.pyprint ' Hello world ' [[email protected] ~]# python 1.pyhello world>>> print ' Hello world ' Hello world>>> exit () [[email protected] ~]#
Python file types
-Python source code file with "py" as extension, interpreted by Python program, do not need to compile
[[email protected] ~]# vim 1.py# python standard format #!/usr/bin/pythonprint ' Hello World ' [[email protected] ~]# chmod +x 1.py[[email Protected] ~]# ls-l 1.py-rwxr-xr-x 1 root root 39 June 08:59 1.py[[email protected] ~]#./1.pyhello World
# Introducing modules, compiling for 1.py [[email protected] shell]# vim 2.pyimport py_compilepy_compile.compile ("1.py") # Compiling with Python [[email Protected] shell]# python 2.py[[email protected] shell]## This generates a file that ends in PYC [[email protected] shell]# ls-l Total usage 12-rwxr-xr- X 1 root root 39 June 08:59 1.py-rw-r--r--1 root root 112 June 10:37 1.pyc-rwxr-xr-x 1 root root 46 June 21 10:37 2. py# This file can also be executed [[email protected] shell]# python 1.pychello World
[[email protected] shell]# Python-o-M py_compile 1.py[[email protected] shell]# ls-l Total usage 16-rwxr-xr-x 1 root root 39 June 08:59 1.py-rwxr-xr-x 1 root root 112 June 10:37 1.pyc-rwxr-xr-x 1 root root 112 June 10:44 1.pyo-rwxr-xr-x 1 root Root 46 June 10:37 2.py
Three kinds of code execution effects
[[email protected] shell]# python 1.pyhello world[[email protected] shell]# python 1.pychello world[[email protected] Shel l]# python 1.pyohello World
This article is from the "topspeed_king" blog, make sure to keep this source http://mylinuxlife.blog.51cto.com/4706737/1664026
Build python environment and Python file types