Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Raspberry Pi讀書會#3 - Raspberry Pi Cookbook Ch5, Ch6, Ch7

140,514 views

Published on

第三次 Raspberry Pi 讀書會,讀書內容為 Raspberry Pi Cookbook。本投影片涵蓋第五章(Python 基礎)、第六章(Python Lists and Dictionaries)和第七章(Python 進階)。
http://www.raspberrypi.com.tw/3035/bookclub03/

Published in: Technology
  • Copas Url to Download PDF eBook === http://hellowbookeas.cf/3958454291-Raspberry-Pi-programmieren-mit-Python-(mitp-Professional).html
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/39sFWPG ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Sex in your area is here: ❶❶❶ http://bit.ly/39sFWPG ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Raspberry Pi讀書會#3 - Raspberry Pi Cookbook Ch5, Ch6, Ch7

  1. 1. Raspberry Pi讀書會 #3 - Raspberry Pi Cookbook 台灣樹莓派 <sosorry@raspberrypi.com.tw> Dec 08, 2014
  2. 2. CC (Creative Commons) 姓名標示 — 非商業性 — 相同方式分享 姓名標示 — 你必須給予 適當表彰、提供指向本授權 條款的連結,以及 指出(本作品的原始版本)是否已 被變更。你可以任何合理方式為前述表彰,但不得以 任何方式暗示授權人為你或你的使用方式背書。 非商業性 — 你不得將本素材進行商業目的之使 用。 相同方式分享 — 若你重混、轉換本素材,或依本 素材建立新素材,你必須依本素材的授權條款來 散布你的貢獻物。
  3. 3. 3 本次領讀章節 ● 5. Python Basics ● 6. Python Lists and Dictionaries ● 7. Advanced Python
  4. 4. 4 Python 2 vs. Python 3 ● Python 3 from 2008/12 ● Python 2.7.2 為最後版本 ● 差異(3的優點): ● 更強大的函式庫:concurrent, enum, asyncio... ● Str型態內建已unicode儲存 ● 2014-09版本已內建 ● 為什麼不要用3(或缺點)? ● 如果已經有大量的程式在production上 更多改變:https://wiki.python.org/moin/Python2orPython3
  5. 5. 5 變數, 物件, 型別, 註解 ● 動態型別(dynamic typing) # 這是註解 i = 3 # 變數i指到數字物件3 i = [1, 2, 3, 4, 5] # 變數i指到串列物件 print( i[2] ) # 印出串列中第三個元素 i = “abcde” # 變數i指到字串物件 print( i[2] ) # 印出字串中第三個元素
  6. 6. 6 ● 相連(+) ● “abc” + “def” ● 數字轉型, 字串轉型 ● str(123), int(“-123”) ● 字串長度 ● len(“abcdef”) ● 字串擷取 ● s = “abcdefghi” ● s[1:5], s[ :5], s[3: ] ● s[-3: ] 字串用法
  7. 7. 7 ● 用縮排取代大括號 縮排 ● 程式碼的區塊是用縮排分隔 ● 不使用tab, 使用空白鍵 ● 常見縮排為4個空白鍵
  8. 8. 8 條件判斷 / 迴圈 / while敘述 # if / elif x = 17 if x>= 10 and x<= 20: print("x is in the middle") # for loop for i in range(1, 11, 2): print(i) # while loop answer = '' while answer != 'X': answer = input('Enter command: ')
  9. 9. 9 List ● list:類似無型別的陣列 ● a = [34, 'Fred', 12, False, 72.3] a[1], len(a) a.append(“new”), a.extend(74, 75) a.pop(), a.pop(0) a[1:3], a[ :3], a[-2: ]
  10. 10. 10 Iterating & Enumerating a list a = [34, 'Fred', 12, False, 72.3] for x in a: print(x) a = [34, 'Fred', 12, False, 72.3] for (i, x) in enumerate(a): print(i, x)
  11. 11. 11 Dictionary ● 需要key-value的存取 a = {'key1':'value1', 'key2':'value2'} a['key1'] a['foo'] = 'bar' a.pop('key2')
  12. 12. 12 def count(from_num=1, to_num=10): for i in range(from_num., to_num+1): print(i) count() count(5) count(5, 10) 函式
  13. 13. 13 類別 class Person: def __init__(self, first_name, surname, tel): self.first_name = first_name self.surname = surname self.tel = tel def full_name(self): return self.first_name + " " + self.surname p = Person("Xiao-Min", "Wang", "1234567") p.full_name()
  14. 14. 14 模組 # import MODULE_NAME import RPi.GPIO # import MODULE_NAME as ALIAS_NAME import RPi.GPIO as GPIO # from MODULE_NAME import FUNCTION_NAME from time import sleep
  15. 15. 15 用Bottle寫一個簡單的Web Server ● 安裝必要的套件 ● sudo apt-get update ● sudo apt-get install python-dev python-pip ● sudo pip install bottle ● 建立一目錄web, 包含兩個檔案server.py和foobar.tpl, 結構如下 $ tree web/ web/ |-- foobar.tpl `-- server.py ● 執行 $ python server.py
  16. 16. 16 server.py from bottle import route, run, debug, template @route('/hello') def hello(): return "Hello World!" @route('/foo') def bar(): output = template("foobar", rows=[34, 'Fred', 12, False, 72.3]) return output run(host='0.0.0.0', port=8080, debug=True)
  17. 17. 17 foobar.tpl <table border="1"> %for (i, x) in enumerate(rows): <tr> <td>{{i}}</td> <td>{{x}}</td> </tr> %end </table>
  18. 18. 18 Demo
  19. 19. Raspberry Pi Rocks the World Thanks

×