
Python 的中文是蟒蛇的意思,英文發音近「派森」或「派嗓」,最早是荷蘭人 Guido van Rossum 於西元 1989 年開發的程式語言 (programming language) ,目前由 Python 軟體基金會維護,以下為 Python 的標幟 (logo)

Python 這個名字來自英國 BBC 的電視劇 Monty Python's Flying Circus , Guido van Rossum 本人是這個電視劇的忠實觀眾,至於「派森」偏英國發音,「派嗓」則偏美國發音。
Guido van Rossum 目前仍是 Python 社群的主要領導者,他是仁慈的獨裁者 (benevolent dictator for life) 。
Python 軟體基金會官網的網址為 https://www.python.org/ ,以下為首頁的截圖

官網就包含非常多的資訊,像是簡介、文件、社群、新聞等等,也提供線上互動的直譯器,例如點擊下面紅色圈起來的黃色按鈕,就會出現另一個黑底白字的 Launch Interactive Shell 按鈕

繼續點擊 Launch Interactive Shell 按鈕,就會跳出基於 IPython 的網頁互動介面

此時就可以直接在上面寫 Python 程式囉!例如經典範例就是印出 Hello World!

印出 Hello World! 之所以經典,因為它是 The C Programming Language 的第一個範例,這本書在西元 1978 年出版,後續影響除了促使 C 語言廣為流傳外,也是一本程式技術書籍的典範。
倒是這個線上直譯器的缺點是只能在網路連線的時候使用,因為它需要跟 PythonAnywhere 連線,也就是把使用者在網頁中的輸入傳送到 PythonAnywhere ,由 PythonAnywhere 計算出結果後再送回使用者的電腦,最後在網頁中顯示結果。
使用 Mac 或 Linux 電腦,系統就有預設安裝 Python ,版本可能是 2 或 3 其中之一,如果需要另一版的 Python 或是 Windows 使用者,就需要從官網下載 Python 來安裝了。下面是 Python 的下載頁面

Python 2 與 Python 3 其實有不少差別,詳細可點擊官網 Here’s more about the difference between Python 2 and 3. 來研究,目前持續推出 2.x 的版本是為了過渡到 3 去,因為絕大多數的第三方模組庫仍在使用 Python 2 ,所以為了協助開發者轉移到 Python 3 ,所以 Python 軟體基金會目前持續提供 Python 2 的支援。
Mac 中預設安裝的是 Python 2 ,打開「終端機」輸入指令 python 就可進入 Python 的互動式開發介面

Windows 使用者可能需要額外設定命令列路徑才能在命令列直接使用 Python ,請參考 Python 於MS-Windows 的命令列路徑設定。
>>> 是互動式介面的提示符號,代表程式碼的一行,上面輸入 print("Hello World") 後按下 Enter 或 return 鍵,執行結果就出現在 >>> 底下的一行,緊接著出現的 >>> 就要求繼續輸入程式碼。
如果要離開互動式介面,請輸入 exit() 函數 (function) 。
甫進入互動式介面,除了版本資訊外,也提示輸入 "help" 、 "copyright" 、 "credits" 及 "license" 可獲得更多資訊。實際輸入時要拿掉雙引號, help() 是文件查詢函數,可用任何 Python 關鍵字 (keyword) 或內建識別字 (identifier) 當參數 (paramenter) 查看文件內容,而 copyright 印出所有權資訊, credits 印出感謝字樣, license 則印出 Python 的授權許可證。
如果只輸入 help() 不帶參數,就會進入文件查詢的互動介面,如下

如果要離開文件查詢介面,請輸入 quit 指令。
例如輸入 if 按下 Enter 或 return 鍵

請按 q 回到文件查詢介面。
如果有從官網下載安裝新版的 Python ,就會連帶安裝視窗版的 IDLE 介面,開啟後如下圖

上圖的警告訊息是指 Mac 裡的 Tcl/Tk 版本會造成 IDLE 不穩定,詳細資訊請參考圖中的網址。
IDLE 就是把互動式換成視窗版而已,實際使用跟網頁版本或命令列版本一樣。
事實上, Python 的所有文件都可在官網找到,如下圖可選擇任一 Python 版本的文件

共有十一份文件,以上圖 3.4.3 的版本為例,整理每份文件的連結如下
- What's new in Python 3.4?
- Tutorial
- Library Reference
- Language Reference
- Python Setup and Usage
- Python HOWTOs
- Installing Python Modules
- Distributing Python Modules
- Extending and Embedding
- Python/C API
- FAQs
就初學新手而言,可以先從 Tutorial 著手,然後學會看懂 Library Reference ,知道怎麼查資料,基本上這樣用純 Python 開發軟體就不會用太大的困難了,至於其他的文件內容都可依需要閱讀。
Python 在台灣也有使用者群組,網址為 http://wiki.python.org.tw/

其內除了提供 Python 的初步教學,也有 Python 各類繁體中文的新手資源整理,如以下網頁

女性也有名為 PyLadies 的專屬聚會,網址為 http://tw.pyladies.com/

Python 的網路資源及書籍都非常豐富,不過大多數都是英文內容,所以新手想要進一步深入 Python 的世界的話,需要先練好英文的語感囉!
the end
Python 新手之旅 V1.10 (Google Play)
沒有留言:
張貼留言