1. 程式人生 > >2 python介紹

2 python介紹

推出 ice its c++ 函數 Language cte 輸出信息 xtend

1.Python介紹:龜叔

python的創始人為吉多·範羅蘇姆(Guido van Rossum)1989年的聖誕節期間Guido開始寫Python語言的編譯器。Python這個名字,來自Guido所摯愛的電視劇Monty Python’s Flying Circus。

他希望這個新的叫做Python的語言,能符合他的理想:創造一種C和shell之間,功能全面,易學易用,可拓展的語言。

2.Python的發展史

1989年,Guido開始寫Python語言的編譯器。

1991年,第一個Python編譯器誕生。它是用C語言實現的,並能夠調用C語言的庫文件。從一出生,Python已經具有了:類,函數,異常處理,包含表和詞典在內的核心數據類型,以及模塊為基礎的拓展系統。

Granddaddy of Python web frameworks, Zope 1 was released in 1999

Python 1.0 - January 1994 增加了 lambda, map, filter and reduce.

Python 2.0 - October 16, 2000,加入了內存回收機制,構成了現在Python語言框架的基礎

Python 2.4 - November 30, 2004, 同年目前最流行的WEB框架Django 誕生

Python 2.5 - September 19, 2006

Python 2.6 - October 1, 2008

Python 3.0 - December 3, 2008 (這裏要解釋清楚 為什麽08年就出3.0,2010年反而又推出了2.7?是因為3.0不向下兼容2.0,導致大家都拒絕升級3.0,無奈官方只能推出2.7過渡版本)

Python 2.7 - July 3, 2010

In November 2014, it was announced that Python 2.7 would be supported until 2020, and reaffirmed that there would be no 2.8 release as users were expected to move to Python 3.4+ as soon as possible

Python 3.1 - June 27, 2009

Python 3.2 - February 20, 2011

Python 3.3 - September 29, 2012

Python 3.4 - March 16, 2014

Python 3.5 - September 13, 2015

Python 3.6 - 2016-12-23 發布python3.6.0版

3.Python 有哪些種類?

技術分享圖片

CPython

當我們從Python官方網站下載並安裝好Python 2.7後,我們就直接獲得了一個官方版本的解釋器:CPython。這個解釋器是用C語言開發的,所以叫CPython。在命令行下運行python就是啟動CPython解釋器。

CPython是使用最廣且被的Python解釋器。教程的所有代碼也都在CPython下執行。

PyPy

PyPy是另一個Python解釋器,它的目標是執行速度。PyPy采用JIT技術,對Python代碼進行動態編譯(註意不是解釋),所以可以顯著提高Python代碼的執行速度。

絕大部分Python代碼都可以在PyPy下運行,但是PyPy和CPython有一些是不同的,這就導致相同的Python代碼在兩種解釋器下執行可能會有不同的結果。如果你的代碼要放到PyPy下執行,就需要了解PyPy和CPython的不同點。

4.Python 2 or Python 3 ?

In summary : Python 2.x is legacy, Python 3.x is the present and future of the language

Python 3.0 was released in 2008. The final 2.x version 2.7 release came out in mid-2010, with a statement of

extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is

under active development and has already seen over five years of stable releases, including version 3.3 in 2012,

3.4 in 2014, and 3.5 in 2015. This means that all recent standard library improvements, for example, are only

available by default in Python 3.x.

Guido van Rossum (the original creator of the Python language) decided to clean up Python 2.x properly, with less regard for backwards compatibility than is the case for new releases in the 2.x range. The most drastic improvement is the better Unicode support (with all text strings being Unicode by default) as well as saner bytes/Unicode separation.

Besides, several aspects of the core language (such as print and exec being statements, integers using floor division) have been adjusted to be easier for newcomers to learn and to be more consistent with the rest of the language, and old cruft has been removed (for example, all classes are now new-style, "range()" returns a memory efficient iterable, not a list as in 2.x).

5.第一個python程序

掌握Python代碼的2種執行方式

1.文件執行

  1. 用notepad++創建一個文件,輸入以下代碼
  2. print("Hello World!")
    print("Python好簡單呀,我要學好掙大錢!")
  3. 保存為HelloWorld.py , 註意要強調.py後綴名的作用
  4. 進入cmd命令行,執行python HelloWorld.py, 看結果 (註意要解釋文件名前面加python 的原因是要把代碼交給python解釋器去解釋執行)
C:\Users\Administrator\Desktop>python HelloWorld.py
Hello World
學好掙大錢

# 後綴名對python沒有影響
C:\Users\Administrator\Desktop>python HelloWorld
Hello World
學好掙大錢

2.交互器執行:調試用的

演示在python交互器下 ,輸出hello world !

要強調python交互器是主要用來對代碼進行調試用的

C:\Users\Administrator\Desktop>python
Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)]
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print("Hello World")
Hello World
>>>

6.精通各種語言的Hello World

C++

#include <iostream>
 int main(void)
 {
  std::cout<<"Hello world";
 }

C

#include <stdio.h>
int main(void)
{
printf("\nhello world!");
return 0;
}

JAVA

public class HelloWorld{
  // 程序的入口
  public static void main(String args[]){
    // 向控制臺輸出信息
    System.out.println("Hello World!");
  }
}

PHP

<?php  
             echo "hello world!";  
?>

Ruby

日本人開發的,敏感時期容易挨K

 puts "Hello world."

GO

package main

import "fmt"

func main(){

    fmt.Printf("Hello World!\n God Bless You!");

}

2 python介紹