• Python基础(一)


    本章内容:

    • Python 的种类
    • Python 的环境
    • Python 入门(解释器、编码、pyc文件、脚步传入参数、变量、输入、流程控制与缩进、while循环)
    • 练习题

     ----------------------------------------------------------- ---^_^---  -----------------------------------------------------------

     Python种类

    • Cpython

      Python的官方版本,使用C语言实现,使用最为广泛,CPython实现会将源文件(py文件)转换成字节码文件(pyc文件),然后运行在Python虚拟机上。

    • Jyhton

      Python的Java实现,Jython会将Python代码动态编译成Java字节码,然后在JVM上运行。

    • IronPython

        Python的C#实现,IronPython将Python代码编译成C#字节码,然后在CLR上运行。(与Jython类似)

    • PyPy(特殊)

      Python实现的Python,将Python的字节码字节码再编译成机器码。

    • RubyPython、Brython ...

     ----------------------------------------------------------- ---^_^---  -----------------------------------------------------------

    Python的环境

    下载地址:https://www.python.org/downloads/

    • Windows下安装

    下载对应msi文件,安装,下一步,下一步。

    • Linux

    系统默认自带的python版本略低,一般为2.6.5版本

    下载源码包

    ./configure --prefix=/usr/local/python27

    or ./configure --prefix=/usr/local/python35

    make all

    make install

    安装完毕后,新建软连接

    ln -s /usr/local/python27/bin/python /usr/local/bin/python2.7

    or

    ln -s /usr/local/python35/bin/python /usr/local/bin/python3

     ----------------------------------------------------------- ---^_^---  -----------------------------------------------------------

    python入门

    (在Linux下演示,主要以python3演示)

    1.hello world

    python2.7进入交互界面(>>>为提示符,下同)

    >>> print "hello, world!"

    python3进入交互界面

    >>> print("hello, world!")

    2.脚本方式执行

    3.编码问题

    python2和python3的不同,python默认以utf-8编码

    4.注释

    单行注释: # comments

    多行注释:

    """ comments """

    ''' comments '''

    5.pyc文件

    6.脚本传参

    import sys

    print(sys.argv)

    7.变量

    变量定义

    变量内存地址(str,int; other)

    8.输入

    python2

        raw_input()

        input()

    python3

      input()

    import getpass

      getpass.getpass()

    9.流程控制

    if-elif-else

    for-loop

    while-loop

    break

    continue

    pass

  • 相关阅读:
    ObjectQuery查询及方法
    SQL系列(十三)—— 关于表的DDL
    SQL系列(十二)—— insert update delete
    Git Push 避免用户名和密码方法
    Git系列 —— github提交一个空目录
    Git系列 —— 记一次Mac上git push时总是403的错误
    Mysql系列(三)—— Mysql主从复制配置
    SQL系列(十一)—— 函数(function)
    SQL系列(十)—— 联结(join)
    动态代理(二)—— CGLIB代理原理
  • 原文地址:https://www.cnblogs.com/wpahu10/p/5795472.html
Copyright © 2020-2023  润新知