1. 程式人生 > >python入門第1篇 python簡介

python入門第1篇 python簡介

內存回收 行數據 pat uid placed 數值 數據 之間 機會

一、python介紹

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

最新的TIOBE排行榜,Python占據第4, Python崇尚優美、清晰、簡單,是一個優秀並廣泛使用的語言。

Python在眾多領域有廣泛應用,如:雲計算、大數據、數據分析、圖像處理、數值計算和科學計算等眾多領域。目前業內幾乎所有大中型互聯網企業都在使用Python,如:Youtube、Dropbox、BT、Quora(中國知乎)、豆瓣、知乎、Google、Yahoo!、Facebook、NASA、百度、騰訊、汽車之家、美團等。

二、目前python的主要領域

  1. WEB開發——最火的Python web框架Django, 支持異步高並發的Tornado框架,短小精悍的flask, django是功能最強大的python web框架,flask是一個微型框架,支持開發者的自由拓展、自由選擇組件,Tornado 是實時 Web 服務的一個 理想框架,支持異步高並發。

  2. 網絡編程——支持高並發的Twisted網絡框架, py3引入的asyncio使異步編程變的非常簡單

  3. 爬蟲——爬蟲領域,Python幾乎是霸主地位,Scrapy\Request\BeautifuSoap\urllib等,使得python在爬蟲領域有著強大的地位

  4. 雲計算——目前最火最知名的雲計算框架就是OpenStack,Python現在的火,很大一部分就是因為雲計算

  5. 人工智能——誰會成為AI 和大數據時代的第一開發語言?這本已是一個不需要爭論的問題。如果說三年前,Matlab、Scala、R、Java 和 Python還各有機會,局面尚且不清楚,那麽三年之後,趨勢已經非常明確了,特別是前兩天 Facebook 開源了 PyTorch 之後,Python 作為 AI 時代頭牌語言的位置基本確立,未來的懸念僅僅是誰能坐穩第二把交椅。

  6. 自動化運維——問問中國的每個運維人員,運維人員必須會的語言是什麽?10個人相信會給你一個相同的答案,它的名字叫Python
  7. 金融分析——到目前,Python是金融分析、量化交易領域裏用的最多的語言
  8. 科學運算—— 97年開始,NASA就在大量使用Python在進行各種復雜的科學運算,隨著NumPy, SciPy, Matplotlib, Enthought librarys等眾多程序庫的開發,使的Python越來越適合於做科學計算、繪制高質量的2D和3D圖像。和科學計算領域最流行的商業軟件Matlab相比,Python是一門通用的程序設計語言,比Matlab所采用的腳本語言的應用範圍更廣泛
  9. 遊戲開發——在網絡遊戲開發中Python也有很多應用。相比Lua or C++,Python 比 Lua 有更高階的抽象能力,可以用更少的代碼描述遊戲業務邏輯,與 Lua 相比,Python 更適合作為一種 Host 語言,即程序的入口點是在 Python 那一端會比較好,然後用 C/C++ 在非常必要的時候寫一些擴展。Python 非常適合編寫 1 萬行以上的項目,而且能夠很好地把網遊項目的規模控制在 10 萬行代碼以內。另外據我所知,知名的遊戲<文明> 就是用Python寫的
  10. 圖像界面開發——Python支持多種圖形界面的第三方庫,包括:PyQT, WxPython,TkInter等等

三、Python在一些公司的應用

  • 谷歌:Google App Engine 、code.google.com 、Google earth 、谷歌爬蟲、Google廣告等項目都在大量使用Python開發
  • CIA: 美國中情局網站就是用Python開發的
  • NASA: 美國航天局(NASA)大量使用Python進行數據分析和運算
  • YouTube:世界上最大的視頻網站YouTube就是用Python開發的
  • Dropbox:美國最大的在線雲存儲網站,全部用Python實現,每天網站處理10億個文件的上傳和下載
  • Instagram:美國最大的圖片分享社交網站,每天超過3千萬張照片被分享,全部用python開發
  • Facebook:大量的基礎庫均通過Python實現的
  • Redhat: 世界上最流行的Linux發行版本中的yum包管理工具就是用python開發的
  • 豆瓣: 公司幾乎所有的業務均是通過Python開發的
  • 知乎: 國內最大的問答社區,通過Python開發(國外Quora)
  • 春雨醫生:國內知名的在線醫療網站是用Python開發的
  • 除上面之外,還有搜狐、金山、騰訊、盛大、網易、百度、阿裏、淘寶 、土豆、新浪、果殼等公司都在使用Python完成各種各樣的任務。

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

py2與3的詳細區別:
PRINT IS A FUNCTION
The statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old statement (PEP 3105). Examples:
Old: print "The answer is", 2*2 New: print("The answer is", 2*2)
Old: print x, # Trailing comma suppresses newline New: print(x, end=" ") # Appends a space instead of a newline
Old: print # Prints a newline
New: print() # You must call the function!
Old: print >>sys.stderr, "fatal error" New: print("fatal error", file=sys.stderr)
Old: print (x, y) # prints repr((x, y))
New: print((x, y)) # Not the same as print(x, y)!
You can also customize the separator between items, e.g.:
print("There are <", 2**32, "> possibilities!", sep="")
ALL IS UNICODE NOW
從此不再為討厭的字符編碼而煩惱

python入門第1篇 python簡介