01-python_下载-安装-使用

0. 下载

官网链接:http://www.python.org/getit/
 CSDN免积分下载: python-2.7.5.msi

1. 启动python --交互模式


 C:\Windows\System32>python
 Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> 1+2
 3
 >>> exit()
 C:\Windows\System32>

2. 编写python --文本模式


 E:\desktop\python\py_src>gvim hello.py

 E:\desktop\python\py_src>type hello.py
 print 'hello world, python!'

 E:\desktop\python\py_src>python hello.py
 hello world, python!

3. 三种可执行文件类型

 (1) .py 
 (2) .pyc
    字节代码, 源文件 编译后 形成的字节码文件
     compile.py
         import py_compile
         py_compile.compile('hello.py')
     python compile.py
        ==> hello.pyc
 (3) .pyo
    经过优化的源文件
    python -O -m py_compile hello.py
        ==> hello.pyo
--------------------------------------------
    E:\desktop\python\py_src>dir /b
    compile.py
    hello.py
    hello.pyc
    hello.pyo

    E:\desktop\python\py_src>python hello.py
    hello world, python!
    E:\desktop\python\py_src>hello.py
    hello world, python!

    E:\desktop\python\py_src>python hello.pyc
    hello world, python!
    E:\desktop\python\py_src>hello.pyc
    hello world, python!

    E:\desktop\python\py_src>python hello.pyo
    hello world, python!
    E:\desktop\python\py_src>hello.pyo

    hello world, python!


你可能感兴趣的:(01-python_下载-安装-使用)