1. 程式人生 > >Python學習筆記整理-->編程語言

Python學習筆記整理-->編程語言

sid reg 來講 異常 oct 全面 res 無奈 第一個

編程語言介紹

1.什麽是編程語言?

首先要明確一點:計算機所能理解的是機器語言(二進制)即(01010)。而二進制太過繁瑣,不便於人類理解。必然要有一種標準化的語言來定義計算機程序的形式語言,即像計算機發送指令。

2.編程語言的發展史

機器語言:

由於計算機內部只能識別二進制碼。因此,用二進制碼描述的指令叫做機器指令,全部機器指令的集合構成計算器的機器語言。

匯編語言:

匯編語言的實質是與機器語言相同的都是對硬件直接進行操作,只不過指令以英文的形式體現,相比機器語言更容易識別與記憶。

高級語言

首先高級語言並不是單純指的某一種語言,高級語言相比機器語言而言。是高度封裝的編程語言,一般使用人易於接受的文字來表示,是的編程語言更加容易理解。

高級語言的區別(分類):

雖然都是高級語言,但是還是有明確的區別的。由於計算機能識別的語言是機器語言,所以即使是高級語言要想被計算機所能識別還是要轉換成機器語言的。而高級語言的區別就是轉換成機器語言的方式不同,即運行速度有不同(面向對象與面向過程這裏不解釋)。

編譯型語言

編譯型語言要想執行,首先要將源代碼編譯生成機器語言,在由機器運行機器碼(比如一個exe文件).

優點:

無需解釋器、執行效率高

缺點:

開發時間成本高(編譯時間)、可移植性差

解釋型語言

解釋型語言在執行的過程中,並不是直接翻譯成機器語言,而是翻譯成中間代碼,在由解釋器對中間代碼進行解釋運行。

優點:

可移植性強、開發時間成本低

缺點:

執行效率低、依賴解釋器

Python的基本概念與發展史

python語言的介紹

python的創始人為吉多·範羅蘇姆(Guido van Rossum)。1989年的聖誕節期間,Guido開始寫Python語言的編譯器。Python這個名字,來自Guido所摯愛的電視劇Monty Python’s Flying Circus。他希望這個新的叫做Python的語言,能符合他的理想:創造一種C和shell之間,功能全面,易學易用,可拓展的語言。

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

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版

Python2與Python3

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).

目前雖然業內很多企業還在大量使用Python2.6 or 2.7,因為舊項目幾十萬甚至上百萬行的代碼想快速升級到3.0不是件容易的事,但是大家在開發新項目時幾乎都會使用3.x。

另外Python3 確實想比2.x做了很多的改進,直觀點來講,就像從XP升級到Win7的感覺一樣,棒棒的。

Py2 和Py3的具體細節區別我們在以後課程中會慢慢深入。

Python學習筆記整理-->編程語言