SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 

Último (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

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