從 REPL 到 IDE

Justin Lin
Justin LinTechnology / Community Evangelist at Free lancer
從 REPL 到 IDE
2. 從 REPL 到 IDE
• 學習目標
– 使用 REPL
– 設定原始碼檔案編碼
– 基本模組與套件管理
– 認識 IDE 的使用
2
使用 REPL
• REPL(Read-Eval-Print Loop,又稱為
Python Shell)
3
4
取得協助訊息
5
6
7
8
• 如果要離開 REPL 環境,可以執行 quit()
函式
9
撰寫 Python 原始碼
10
11
12
哈囉!世界!
• 事物的複雜度不會憑空消失,只會從一個
事物轉移到另一個事物
13
UTF-8
• Python 3 之後,python 直譯器預期的原
始碼檔案編碼必須是 UTF-8
14
• 使用註解設定編碼資訊
• 在 Python 原始碼檔案中,# 開頭代表這
是一行註解
15
• 到其他的編碼設定方式
• python 直譯器只要在註解中看到
coding=<encoding name> 或者
coding: <encoding name> 出現
# -*- coding: Big5 -*-
# vim: set fileencoding=Big5 :
16
簡介模組
• 每個 .py 檔案本身就是一個模組
• 直接重用先前撰寫好的 hello2.py 檔案
17
• Python 本身提供有標準程式庫
18
• 如果有多個模組需要 import,除了逐行
import 之外,也可以在單一行中使用逗號
「,」來區隔模組
• 在 __builtins__模組中的函式、類別等
名稱,都可以不用 import 直接取用,而
且不用加上模組名稱作為前置
import sys, email
19
設定 PYTHONPATH
• 可以設定 PYTHONPATH 環境變數來解決這
個問題:
20
21
• 想要動態地管理模組的尋找路徑, 也可以
透過程式變更 sys.path 的內容來達到
22
使用套件管理模組
• 模組也應該分門別類加以放置
• 一定要有一個__init__.py 檔案,該資料夾
才會被視為一個套件
• 在套件的進階管理中,__init__.py 中其實
也可以撰寫程式
23
• 套件名稱會成為名稱空間的一部份
• 可以建立多層次的套件,每個擔任套件的
資料夾與子資料夾中,各要有一個
__init__.py
24
import as、from import
• import as
• from import
25
• 如果有多個名稱想要直接匯入目前模組,
除了逐行 from import 之外,也可以在
單一行中使用逗號「,」來區隔
• 更偷懶一點(不建議)
26
使用IDE
• PyCharm(www.jetbrains.com/pycharm/)
• PyDev(www.pydev.org/)
• Komodo IDE(komodoide.com/)
• Spyder
(code.google.com/archive/p/spyderlib/)
• WingIDE(wingware.com/)
• NINJA-IDE(www.ninja-ide.org/)
• Python Tools for Visual Studio
(pytools.codeplex.com/)
27
1 of 27

Recommended

從 REPL 到 IDE by
從 REPL 到 IDE從 REPL 到 IDE
從 REPL 到 IDEJustin Lin
2.3K views27 slides
《Python 3.5 技術手冊》第二章草稿 by
《Python 3.5 技術手冊》第二章草稿《Python 3.5 技術手冊》第二章草稿
《Python 3.5 技術手冊》第二章草稿Justin Lin
4.5K views28 slides
open() 與 io 模組 by
open() 與 io 模組open() 與 io 模組
open() 與 io 模組Justin Lin
1.8K views40 slides
函数调用关系工具-2011-孙光福 by
函数调用关系工具-2011-孙光福函数调用关系工具-2011-孙光福
函数调用关系工具-2011-孙光福Wu Liang
709 views31 slides
Python 起步走 by
Python 起步走Python 起步走
Python 起步走Justin Lin
7.2K views26 slides
Device Driver - Chapter 6字元驅動程式的進階作業 by
Device Driver - Chapter 6字元驅動程式的進階作業Device Driver - Chapter 6字元驅動程式的進階作業
Device Driver - Chapter 6字元驅動程式的進階作業ZongYing Lyu
973 views33 slides

More Related Content

What's hot

Python 编程艺术 by
Python 编程艺术Python 编程艺术
Python 编程艺术wilhelmshen
7.8K views61 slides
Erlang jiacheng by
Erlang jiachengErlang jiacheng
Erlang jiachengAir-Smile
1.4K views25 slides
Php Extension--yahoo(Cc0cc) by
Php Extension--yahoo(Cc0cc)Php Extension--yahoo(Cc0cc)
Php Extension--yahoo(Cc0cc)sunlick
418 views9 slides
Python系列3 by
Python系列3Python系列3
Python系列3數真 蔡
396 views43 slides
Free rtos workshop1@nuu by
Free rtos workshop1@nuuFree rtos workshop1@nuu
Free rtos workshop1@nuu紀榮 陳
183 views31 slides
Python系列4 by
Python系列4Python系列4
Python系列4數真 蔡
456 views101 slides

What's hot(9)

Python 编程艺术 by wilhelmshen
Python 编程艺术Python 编程艺术
Python 编程艺术
wilhelmshen7.8K views
Erlang jiacheng by Air-Smile
Erlang jiachengErlang jiacheng
Erlang jiacheng
Air-Smile1.4K views
Php Extension--yahoo(Cc0cc) by sunlick
Php Extension--yahoo(Cc0cc)Php Extension--yahoo(Cc0cc)
Php Extension--yahoo(Cc0cc)
sunlick418 views
Python系列3 by 數真 蔡
Python系列3Python系列3
Python系列3
數真 蔡396 views
Free rtos workshop1@nuu by 紀榮 陳
Free rtos workshop1@nuuFree rtos workshop1@nuu
Free rtos workshop1@nuu
紀榮 陳183 views
Python系列4 by 數真 蔡
Python系列4Python系列4
Python系列4
數真 蔡456 views
[ZigBee 嵌入式系統] ZigBee Architecture 與 TI Z-Stack Firmware by Simen Li
[ZigBee 嵌入式系統] ZigBee Architecture 與 TI Z-Stack Firmware[ZigBee 嵌入式系統] ZigBee Architecture 與 TI Z-Stack Firmware
[ZigBee 嵌入式系統] ZigBee Architecture 與 TI Z-Stack Firmware
Simen Li14.6K views
Python系列1 by 數真 蔡
Python系列1Python系列1
Python系列1
數真 蔡759 views
Erlang开发及应用 by litaocheng
Erlang开发及应用Erlang开发及应用
Erlang开发及应用
litaocheng1.4K views

Similar to 從 REPL 到 IDE

2. 從 REPL 到 IDE by
2. 從 REPL 到 IDE2. 從 REPL 到 IDE
2. 從 REPL 到 IDEJustin Lin
234 views28 slides
Python01 by
Python01Python01
Python01俊杰 李
199 views15 slides
執行緒與並行API by
執行緒與並行API執行緒與並行API
執行緒與並行APIJustin Lin
878 views133 slides
简单Pthon教程 by
简单Pthon教程简单Pthon教程
简单Pthon教程junjun chen
508 views110 slides
建置Python開發環境 by
建置Python開發環境建置Python開發環境
建置Python開發環境吳錫修 (ShyiShiou Wu)
303 views56 slides
Learn python 2 - Real World Case by
Learn python 2 - Real World CaseLearn python 2 - Real World Case
Learn python 2 - Real World CaseChia-Hao Tsai
465 views47 slides

Similar to 從 REPL 到 IDE(16)

2. 從 REPL 到 IDE by Justin Lin
2. 從 REPL 到 IDE2. 從 REPL 到 IDE
2. 從 REPL 到 IDE
Justin Lin234 views
執行緒與並行API by Justin Lin
執行緒與並行API執行緒與並行API
執行緒與並行API
Justin Lin878 views
简单Pthon教程 by junjun chen
简单Pthon教程简单Pthon教程
简单Pthon教程
junjun chen508 views
Learn python 2 - Real World Case by Chia-Hao Tsai
Learn python 2 - Real World CaseLearn python 2 - Real World Case
Learn python 2 - Real World Case
Chia-Hao Tsai465 views
Java Tutorial:Learn Java in 06:00:00 by Justin Lin
Java Tutorial:Learn Java in 06:00:00Java Tutorial:Learn Java in 06:00:00
Java Tutorial:Learn Java in 06:00:00
Justin Lin27.5K views
Adorable python by Rhythm Sun
Adorable pythonAdorable python
Adorable python
Rhythm Sun489 views
CH10:輸入輸出 by Justin Lin
CH10:輸入輸出CH10:輸入輸出
CH10:輸入輸出
Justin Lin253 views
Continuous Delivery Workshop with Ansible x GitLab CI by Chu-Siang Lai
Continuous Delivery Workshop with Ansible x GitLab CIContinuous Delivery Workshop with Ansible x GitLab CI
Continuous Delivery Workshop with Ansible x GitLab CI
Chu-Siang Lai866 views
Tiptop gp 5.1 setup_instructions by guest994aeb5
Tiptop gp 5.1 setup_instructionsTiptop gp 5.1 setup_instructions
Tiptop gp 5.1 setup_instructions
guest994aeb51.2K views
Oracle Security 101 by Dahui Feng
Oracle Security 101Oracle Security 101
Oracle Security 101
Dahui Feng1.9K views
Web scraping入門1 by 兆欽 丘
Web scraping入門1Web scraping入門1
Web scraping入門1
兆欽 丘645 views
Python简明教程 by ingong
Python简明教程Python简明教程
Python简明教程
ingong1.6K views
2, OCP - installing and creating a database by ted-xu
2, OCP - installing and creating a database2, OCP - installing and creating a database
2, OCP - installing and creating a database
ted-xu465 views
Continuous Delivery with Ansible x GitLab CI (2e) by Chu-Siang Lai
Continuous Delivery with Ansible x GitLab CI (2e)Continuous Delivery with Ansible x GitLab CI (2e)
Continuous Delivery with Ansible x GitLab CI (2e)
Chu-Siang Lai1.9K views

More from Justin Lin

Ch14 簡介 Spring Boot by
Ch14 簡介 Spring BootCh14 簡介 Spring Boot
Ch14 簡介 Spring BootJustin Lin
872 views22 slides
Ch13 整合 Spring MVC/Security by
Ch13 整合 Spring MVC/SecurityCh13 整合 Spring MVC/Security
Ch13 整合 Spring MVC/SecurityJustin Lin
280 views58 slides
Ch12 Spring 起步走 by
Ch12 Spring 起步走Ch12 Spring 起步走
Ch12 Spring 起步走Justin Lin
274 views31 slides
Ch11 簡介 JavaMail by
Ch11 簡介 JavaMailCh11 簡介 JavaMail
Ch11 簡介 JavaMailJustin Lin
157 views8 slides
Ch10 Web 容器安全管理 by
Ch10 Web 容器安全管理Ch10 Web 容器安全管理
Ch10 Web 容器安全管理Justin Lin
153 views30 slides
Ch09 整合資料庫 by
Ch09 整合資料庫Ch09 整合資料庫
Ch09 整合資料庫Justin Lin
233 views92 slides

More from Justin Lin(20)

Ch14 簡介 Spring Boot by Justin Lin
Ch14 簡介 Spring BootCh14 簡介 Spring Boot
Ch14 簡介 Spring Boot
Justin Lin872 views
Ch13 整合 Spring MVC/Security by Justin Lin
Ch13 整合 Spring MVC/SecurityCh13 整合 Spring MVC/Security
Ch13 整合 Spring MVC/Security
Justin Lin280 views
Ch12 Spring 起步走 by Justin Lin
Ch12 Spring 起步走Ch12 Spring 起步走
Ch12 Spring 起步走
Justin Lin274 views
Ch11 簡介 JavaMail by Justin Lin
Ch11 簡介 JavaMailCh11 簡介 JavaMail
Ch11 簡介 JavaMail
Justin Lin157 views
Ch10 Web 容器安全管理 by Justin Lin
Ch10 Web 容器安全管理Ch10 Web 容器安全管理
Ch10 Web 容器安全管理
Justin Lin153 views
Ch09 整合資料庫 by Justin Lin
Ch09 整合資料庫Ch09 整合資料庫
Ch09 整合資料庫
Justin Lin233 views
Ch08 自訂標籤 by Justin Lin
Ch08 自訂標籤Ch08 自訂標籤
Ch08 自訂標籤
Justin Lin133 views
Ch07 使用 JSTL by Justin Lin
Ch07 使用 JSTLCh07 使用 JSTL
Ch07 使用 JSTL
Justin Lin161 views
Ch06 使用 JSP by Justin Lin
Ch06 使用 JSPCh06 使用 JSP
Ch06 使用 JSP
Justin Lin250 views
Ch05 Servlet 進階 API、過濾器與傾聽器 by Justin Lin
Ch05 Servlet 進階 API、過濾器與傾聽器Ch05 Servlet 進階 API、過濾器與傾聽器
Ch05 Servlet 進階 API、過濾器與傾聽器
Justin Lin204 views
Ch04 會話管理 by Justin Lin
Ch04 會話管理Ch04 會話管理
Ch04 會話管理
Justin Lin238 views
Ch03 請求與回應 by Justin Lin
Ch03 請求與回應Ch03 請求與回應
Ch03 請求與回應
Justin Lin236 views
Ch02 撰寫與設定 Servlet by Justin Lin
Ch02 撰寫與設定 ServletCh02 撰寫與設定 Servlet
Ch02 撰寫與設定 Servlet
Justin Lin352 views
CH1. 簡介 Web 應用程式 by Justin Lin
CH1. 簡介 Web 應用程式CH1. 簡介 Web 應用程式
CH1. 簡介 Web 應用程式
Justin Lin1.2K views
14. 進階主題 by Justin Lin
14. 進階主題14. 進階主題
14. 進階主題
Justin Lin406 views
13.並行、平行與非同步 by Justin Lin
13.並行、平行與非同步13.並行、平行與非同步
13.並行、平行與非同步
Justin Lin238 views
12. 除錯、測試與效能 by Justin Lin
12. 除錯、測試與效能12. 除錯、測試與效能
12. 除錯、測試與效能
Justin Lin153 views
11. 常用內建模組 by Justin Lin
11. 常用內建模組11. 常用內建模組
11. 常用內建模組
Justin Lin149 views
10. 資料永續與交換 by Justin Lin
10. 資料永續與交換10. 資料永續與交換
10. 資料永續與交換
Justin Lin156 views
9. 資料結構 by Justin Lin
9. 資料結構9. 資料結構
9. 資料結構
Justin Lin292 views

從 REPL 到 IDE