SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
30 minute of Python



  Name    : Kang-min Wang ( Aminzai )
  Date    : 2010/08/19
  Email   : aminzai –at-- aminzai.net
Outline
      ●   迷漾的 Outline....




                                           2
2010/08/09             30 minutes Python
What's Python?




 一條蟒蛇?


                                   3
2010/08/09     30 minutes Python
What's Python?




                                   4
2010/08/09     30 minutes Python
History
      ●   Python 的創始人為吉多 · 范羅蘇姆。在 1989 年
          聖誕節期間的阿姆斯特丹,吉多為了打發聖誕節
          的無趣,決心開發一個新的指令碼解釋程式
             ●   我們究竟在幹嘛阿 ...




                                                5
2010/08/09                  30 minutes Python
Who use it?
      ●   Google
      ●   Youtube
      ●   BitTorrent
      ●   NASA
      ●   OLPC
      ●   Plurk
      ●   Me 0.0-/


                                           6
2010/08/09             30 minutes Python
2010/08/09   7
Why Google use it?
      ●   由於 Python 對於 C 和其他語言的良好支援,很
          多人還把 Python 作為一種「膠水語言」( glue
          language )使用。使用 Python 將其他語言編寫
          的程式進行整合和封裝。




                                           8
2010/08/09         30 minutes Python
Python's Core ideology
      ●   There is only one way to do it.
          要做好一件事,一種方法就夠了。
      ●   Everything is object.
          萬物皆物件
      ●   Readability counts.
          可讀性優先
      ●   Explicit is better than implicit.
          明顯比隱晦好
      ●   Simple is better than complex.
          簡單比複雜好
                                              9
2010/08/09                30 minutes Python
Advantage
      ●   簡單易讀
      ●   開發快速
      ●   易於協同開發
      ●   很快就可以上手
      ●   記憶體回收機制
      ●   養成良好習慣




                                       10
2010/08/09         30 minutes Python
Shortcoming
      ●   速度仍然比 C 慢
      ●   有些超級老的 cpu 不能跑
      ●   有些模組比較肥 (xml 相關 )




                                       11
2010/08/09         30 minutes Python
Develop Enviorment
      ●   Eclipse + pyDev
      ●   Python IDLE
      ●   Vim <== 我在用的 XD




                                            12
2010/08/09              30 minutes Python
st
                1 example




             Hello, World!

                                     13
2010/08/09       30 minutes Python
Numbers
      ●   整數 (int)
      ●   浮點 (float)
      ●   長整數 (long)
      ●   八進位與十六進位
      ●   複數 (complex)
      ●   布林值 (bool)




                                             14
2010/08/09               30 minutes Python
Operation
      ●   + - * / ** //...
      ●   遵守四則運算規則
      ●   數學函式: pow abs...
      ●   Modules : random math...
      ●   轉換進制: oct() hex()....
          from decimal import Decimal
          Decimal()
      ●   集合 set()


                                                 15
2010/08/09                   30 minutes Python
String
      ●   字串 (str)
      ●   Raw
      ●   Unicode
      ●   byte(in Python 3.0)
      ●   + *...
      ●   len()
      ●   slice notation
      ●   Replace ,Upper....

                                               16
2010/08/09                 30 minutes Python
Slice(array)
              0       1        2                3       4       5




                  S        L              I         C       E
             [:                                                 :]

                          [ 起使:終止:步進 ]


                                                                     17
2010/08/09                  30 minutes Python
List
      ●   [ 'abc', 123 , [ 'a' , 'b' ] ]
      ●   可任意巢狀化,不限定型態




                                                  18
2010/08/09                    30 minutes Python
Tuple
      ●   ( 'abc', 123 , [ 'a' , 'b' ] )
      ●   內含物不可變更的 list




                                                  19
2010/08/09                    30 minutes Python
Dict (Dictory)
      ●   { 'name' : 'billy3321' ,'jobs' : ['student',
          'maintainer'], 'develop' : {'name' : 'lazybuntu',
          'OS' : 'Ubuntu' } }
      ●   Key : Value
      ●   無序集合體,以 key 存取
      ●   以 hash table 實作




                                                              20
2010/08/09                30 minutes Python
File I/O
      ●   myfile = open('myfile', 'w')
          myfile.write('Hello, World!')
          myfile.close()
      ●   myfile = open('myfile', 'r')
          myfile.readline()
          myfile.readline()
          myfile.readline()
          myfile.readlines()
          myfile.close


                                              21
2010/08/09                30 minutes Python
Dynamic type?
      ●   整數,字串是不能改的?我明明就可以改他啊!
      ●   A=3
          B=A
          print A , B
          A = 'hello'
          print A , B
      ●   Refrence( 參照值 ) → object( 物件 )
      ●   屬性是屬於物件的,而變數就是參照值
      ●   [ 'abc' , [(1, 2), ([3],4)],'def']

                                                 22
2010/08/09                   30 minutes Python
[ 'abc' , [(1, 2), ([3],4)],'def']


         'abc'       (1, 2)    ([3],4)          'def'



                 1        2      [3]        4


                                   3
2010/08/09                                              23
Let's think!
               為什麼縮排?




2010/08/09                  24
給你三秒鐘

2010/08/09           25
給你三秒鐘 !!
     if (x)
         if (y)
               statement1;
     else
        statement;
             else
                statement2;



                                                 26
2010/08/09                   30 minutes Python
看完了嘛?

2010/08/09           27
縮排是 Python 的
              其中一重點!




2010/08/09                  28
縮排

      ●      可讀性優先 ; readability counts
      ●      把習慣養好
      ●      方便大家協同作業,大家的程式碼一目瞭然。




                                             29
2010/08/09               30 minutes Python
●
                       While loop
●   while true:
       print "Spam"
    else
       print "Aminzai"
●   while i < 5:
     i=i+1
     print i
●   countinue break pass else
●
                        For loop
●   for i in lists:
      print i
●   for line in open('file'):
●   如果要反覆特定次數:搭配 range()
    for i in range(5)
      print "Spam"
Function
●   def print_aminzai():
      print "Aminzai"

    print_aminzai()
●   利用 return 回傳值
●   注意:變數所存在之範圍
    內建>廣域>函式>區域
Object
●   class Person:
       def __init__(self, name, job):
         self.name = name
         self.job = job
       def info(self):
         return (self.name, self.job)

    aminzai = Person(‘Aminzai’, ‘student’)
    aminzai.job
    aminzai.info()
Object
●   class man(Person):
       self.sex = male

    aminzai = man(‘aminzai’, ‘student’)
    aminzai.sex
    aminzai.info()
Document
      ●   help()
      ●   dir()
      ●   Pydoc
      ●   說明文件和程式碼放在一起




                                       35
2010/08/09         30 minutes Python
2010/08/09   36
2010/08/09   37
Fire Show!!
      ●   Plurk BOT
             ●   http://www.plurk.com/isu_ann
      ●   Lazyscripts
             ●   http://lazyscripts.org
      ●   Google App Engines
             ●   Geeklothes
                 –   http://geeklothes-tw.appspot.com
             ●   ECG Waveform
                 –   http://isucsieeslabecg.appspot.com/SWF
             ●   Conference Joke
                                                              38
2010/08/09
                 –   http://confjoke.appspot.com/
                                   30 minutes Python
Resource
      ●   PyTUG:www.python.org.tw
      ●   irc.://irc.freenode.net/#python.tw
      ●   Ptt Python 討論版
      ●   http://www.python.org/




                                               39
2010/08/09               30 minutes Python
2010/08/09   40
Next Topic



             Hadoop
                          Or

        My Develop Envirment

                                  41
2010/08/09    30 minutes Python

Contenu connexe

En vedette

Lazyscripts Ubuntu Release Party In Tainan 20091107
Lazyscripts Ubuntu Release Party In Tainan 20091107Lazyscripts Ubuntu Release Party In Tainan 20091107
Lazyscripts Ubuntu Release Party In Tainan 20091107Kang-Min Wang
 
2010 07-29-version control use git
2010 07-29-version control use git2010 07-29-version control use git
2010 07-29-version control use gitKang-Min Wang
 
2010 07-19-introduction version control system
2010 07-19-introduction version control system2010 07-19-introduction version control system
2010 07-19-introduction version control systemKang-Min Wang
 
Lazyscripts@SA 20091128
Lazyscripts@SA 20091128Lazyscripts@SA 20091128
Lazyscripts@SA 20091128Kang-Min Wang
 
Ubuntu v.s. Windows 由自由軟體重新出發
Ubuntu v.s. Windows 由自由軟體重新出發Ubuntu v.s. Windows 由自由軟體重新出發
Ubuntu v.s. Windows 由自由軟體重新出發Kang-Min Wang
 
A Brief Introduction to Working with Git
A Brief Introduction to Working with GitA Brief Introduction to Working with Git
A Brief Introduction to Working with GitPhilip Langer
 

En vedette (6)

Lazyscripts Ubuntu Release Party In Tainan 20091107
Lazyscripts Ubuntu Release Party In Tainan 20091107Lazyscripts Ubuntu Release Party In Tainan 20091107
Lazyscripts Ubuntu Release Party In Tainan 20091107
 
2010 07-29-version control use git
2010 07-29-version control use git2010 07-29-version control use git
2010 07-29-version control use git
 
2010 07-19-introduction version control system
2010 07-19-introduction version control system2010 07-19-introduction version control system
2010 07-19-introduction version control system
 
Lazyscripts@SA 20091128
Lazyscripts@SA 20091128Lazyscripts@SA 20091128
Lazyscripts@SA 20091128
 
Ubuntu v.s. Windows 由自由軟體重新出發
Ubuntu v.s. Windows 由自由軟體重新出發Ubuntu v.s. Windows 由自由軟體重新出發
Ubuntu v.s. Windows 由自由軟體重新出發
 
A Brief Introduction to Working with Git
A Brief Introduction to Working with GitA Brief Introduction to Working with Git
A Brief Introduction to Working with Git
 

Similaire à 2010 08-19-30 minutes of python

PyPy 1.2: snakes never crawled so fast
PyPy 1.2: snakes never crawled so fastPyPy 1.2: snakes never crawled so fast
PyPy 1.2: snakes never crawled so fastPyCon Italia
 
Python 3.10の新機能を 俯瞰してみる
Python 3.10の新機能を 俯瞰してみるPython 3.10の新機能を 俯瞰してみる
Python 3.10の新機能を 俯瞰してみるhiroya akita
 
Everything Rubinius
Everything RubiniusEverything Rubinius
Everything RubiniusEngine Yard
 
开源沙龙第一期 Python intro
开源沙龙第一期 Python intro开源沙龙第一期 Python intro
开源沙龙第一期 Python introfantasy zheng
 
Python on a chip
Python on a chipPython on a chip
Python on a chipstoggi
 
PyCon JP 2011 Lightning Talk No.10
PyCon JP 2011 Lightning Talk No.10PyCon JP 2011 Lightning Talk No.10
PyCon JP 2011 Lightning Talk No.10Yoji TAKEUCHI
 

Similaire à 2010 08-19-30 minutes of python (11)

PyPy 1.2: snakes never crawled so fast
PyPy 1.2: snakes never crawled so fastPyPy 1.2: snakes never crawled so fast
PyPy 1.2: snakes never crawled so fast
 
Python 3.10の新機能を 俯瞰してみる
Python 3.10の新機能を 俯瞰してみるPython 3.10の新機能を 俯瞰してみる
Python 3.10の新機能を 俯瞰してみる
 
Rusty Python
Rusty PythonRusty Python
Rusty Python
 
Everything Rubinius
Everything RubiniusEverything Rubinius
Everything Rubinius
 
开源沙龙第一期 Python intro
开源沙龙第一期 Python intro开源沙龙第一期 Python intro
开源沙龙第一期 Python intro
 
Python introduction
Python introductionPython introduction
Python introduction
 
Violent python
Violent pythonViolent python
Violent python
 
Python on a chip
Python on a chipPython on a chip
Python on a chip
 
肉体言語 Tython
肉体言語 Tython肉体言語 Tython
肉体言語 Tython
 
What is Python?
What is Python?What is Python?
What is Python?
 
PyCon JP 2011 Lightning Talk No.10
PyCon JP 2011 Lightning Talk No.10PyCon JP 2011 Lightning Talk No.10
PyCon JP 2011 Lightning Talk No.10
 

Dernier

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 

Dernier (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 

2010 08-19-30 minutes of python

  • 1. 30 minute of Python Name : Kang-min Wang ( Aminzai ) Date : 2010/08/19 Email : aminzai –at-- aminzai.net
  • 2. Outline ● 迷漾的 Outline.... 2 2010/08/09 30 minutes Python
  • 3. What's Python? 一條蟒蛇? 3 2010/08/09 30 minutes Python
  • 4. What's Python? 4 2010/08/09 30 minutes Python
  • 5. History ● Python 的創始人為吉多 · 范羅蘇姆。在 1989 年 聖誕節期間的阿姆斯特丹,吉多為了打發聖誕節 的無趣,決心開發一個新的指令碼解釋程式 ● 我們究竟在幹嘛阿 ... 5 2010/08/09 30 minutes Python
  • 6. Who use it? ● Google ● Youtube ● BitTorrent ● NASA ● OLPC ● Plurk ● Me 0.0-/ 6 2010/08/09 30 minutes Python
  • 8. Why Google use it? ● 由於 Python 對於 C 和其他語言的良好支援,很 多人還把 Python 作為一種「膠水語言」( glue language )使用。使用 Python 將其他語言編寫 的程式進行整合和封裝。 8 2010/08/09 30 minutes Python
  • 9. Python's Core ideology ● There is only one way to do it. 要做好一件事,一種方法就夠了。 ● Everything is object. 萬物皆物件 ● Readability counts. 可讀性優先 ● Explicit is better than implicit. 明顯比隱晦好 ● Simple is better than complex. 簡單比複雜好 9 2010/08/09 30 minutes Python
  • 10. Advantage ● 簡單易讀 ● 開發快速 ● 易於協同開發 ● 很快就可以上手 ● 記憶體回收機制 ● 養成良好習慣 10 2010/08/09 30 minutes Python
  • 11. Shortcoming ● 速度仍然比 C 慢 ● 有些超級老的 cpu 不能跑 ● 有些模組比較肥 (xml 相關 ) 11 2010/08/09 30 minutes Python
  • 12. Develop Enviorment ● Eclipse + pyDev ● Python IDLE ● Vim <== 我在用的 XD 12 2010/08/09 30 minutes Python
  • 13. st 1 example Hello, World! 13 2010/08/09 30 minutes Python
  • 14. Numbers ● 整數 (int) ● 浮點 (float) ● 長整數 (long) ● 八進位與十六進位 ● 複數 (complex) ● 布林值 (bool) 14 2010/08/09 30 minutes Python
  • 15. Operation ● + - * / ** //... ● 遵守四則運算規則 ● 數學函式: pow abs... ● Modules : random math... ● 轉換進制: oct() hex().... from decimal import Decimal Decimal() ● 集合 set() 15 2010/08/09 30 minutes Python
  • 16. String ● 字串 (str) ● Raw ● Unicode ● byte(in Python 3.0) ● + *... ● len() ● slice notation ● Replace ,Upper.... 16 2010/08/09 30 minutes Python
  • 17. Slice(array) 0 1 2 3 4 5 S L I C E [: :] [ 起使:終止:步進 ] 17 2010/08/09 30 minutes Python
  • 18. List ● [ 'abc', 123 , [ 'a' , 'b' ] ] ● 可任意巢狀化,不限定型態 18 2010/08/09 30 minutes Python
  • 19. Tuple ● ( 'abc', 123 , [ 'a' , 'b' ] ) ● 內含物不可變更的 list 19 2010/08/09 30 minutes Python
  • 20. Dict (Dictory) ● { 'name' : 'billy3321' ,'jobs' : ['student', 'maintainer'], 'develop' : {'name' : 'lazybuntu', 'OS' : 'Ubuntu' } } ● Key : Value ● 無序集合體,以 key 存取 ● 以 hash table 實作 20 2010/08/09 30 minutes Python
  • 21. File I/O ● myfile = open('myfile', 'w') myfile.write('Hello, World!') myfile.close() ● myfile = open('myfile', 'r') myfile.readline() myfile.readline() myfile.readline() myfile.readlines() myfile.close 21 2010/08/09 30 minutes Python
  • 22. Dynamic type? ● 整數,字串是不能改的?我明明就可以改他啊! ● A=3 B=A print A , B A = 'hello' print A , B ● Refrence( 參照值 ) → object( 物件 ) ● 屬性是屬於物件的,而變數就是參照值 ● [ 'abc' , [(1, 2), ([3],4)],'def'] 22 2010/08/09 30 minutes Python
  • 23. [ 'abc' , [(1, 2), ([3],4)],'def'] 'abc' (1, 2) ([3],4) 'def' 1 2 [3] 4 3 2010/08/09 23
  • 24. Let's think! 為什麼縮排? 2010/08/09 24
  • 26. 給你三秒鐘 !! if (x) if (y) statement1; else statement; else statement2; 26 2010/08/09 30 minutes Python
  • 28. 縮排是 Python 的 其中一重點! 2010/08/09 28
  • 29. 縮排 ● 可讀性優先 ; readability counts ● 把習慣養好 ● 方便大家協同作業,大家的程式碼一目瞭然。 29 2010/08/09 30 minutes Python
  • 30. While loop ● while true: print "Spam" else print "Aminzai" ● while i < 5: i=i+1 print i ● countinue break pass else
  • 31. For loop ● for i in lists: print i ● for line in open('file'): ● 如果要反覆特定次數:搭配 range() for i in range(5) print "Spam"
  • 32. Function ● def print_aminzai(): print "Aminzai" print_aminzai() ● 利用 return 回傳值 ● 注意:變數所存在之範圍 內建>廣域>函式>區域
  • 33. Object ● class Person: def __init__(self, name, job): self.name = name self.job = job def info(self): return (self.name, self.job) aminzai = Person(‘Aminzai’, ‘student’) aminzai.job aminzai.info()
  • 34. Object ● class man(Person): self.sex = male aminzai = man(‘aminzai’, ‘student’) aminzai.sex aminzai.info()
  • 35. Document ● help() ● dir() ● Pydoc ● 說明文件和程式碼放在一起 35 2010/08/09 30 minutes Python
  • 38. Fire Show!! ● Plurk BOT ● http://www.plurk.com/isu_ann ● Lazyscripts ● http://lazyscripts.org ● Google App Engines ● Geeklothes – http://geeklothes-tw.appspot.com ● ECG Waveform – http://isucsieeslabecg.appspot.com/SWF ● Conference Joke 38 2010/08/09 – http://confjoke.appspot.com/ 30 minutes Python
  • 39. Resource ● PyTUG:www.python.org.tw ● irc.://irc.freenode.net/#python.tw ● Ptt Python 討論版 ● http://www.python.org/ 39 2010/08/09 30 minutes Python
  • 41. Next Topic Hadoop Or My Develop Envirment 41 2010/08/09 30 minutes Python