Upgrade to Pro — share decks privately, control downloads, hide ads and more …

麻瓜也能上手的爬說語:開源社 Python 入門

Poren Chiang
October 03, 2014

麻瓜也能上手的爬說語:開源社 Python 入門

2014/10/3 Talk @ NTU Open Source Community, NTUCC, Taipei, Taiwan.
Licensed under CC BY-SA 4.0.

Poren Chiang

October 03, 2014
Tweet

More Decks by Poren Chiang

Other Decks in Technology

Transcript

  1. 란 檘 ⛳ 腋 ♳ 䩛 涸
    昮铞铃
    շ〵㣐Ꟛ彂爢1ZUIPOⰅꟌո
    (C) RSChiang @ NTUOSC / CC BY-SA 4.0

    View full-size slide

  2. Ꟛ㨥⛓⵹
    ˖ 瘘鎹㘗ꨶ舡鎙⚥呲堥
    ˖ 1ZUIPO
    • ጐ⼎ḑ⋣ⶤ⼗⌀㡠ping 8.8.8.8㡡

    View full-size slide

  3. 玑䒭
    ˖ Ⱖ㻜㽠僽雊ꨶ舡㛂遤䭸⟂涸䠑䙼
    ˖ 䩧⦐嫲倰ĈĈ

    View full-size slide

  4. 欰崞⚥涸玑䒭
    ˖ 㕮䕎⢪欽罏歲꬗
    ˖ չ殥ⴀ殥꬗瘞䖊䭸⟂պ涸鶬㕖

    View full-size slide

  5. ず㷸⟃捀䧮僽 㹻酭⟃捀䧮僽
    䧮⟃捀䧮僽 㻜ꥹ♳䧮僽
    1IPUPDSFEJU#SJBO,MVH UPQMFGU $$#:/$
    "EBN5IPNBT UPQSJHIU $$#:
    8BSOFS#SPT1JDUVSFT CPUUPNMFGU
    QPXUBD CPUUPNSJHIU $$#:/$/%

    View full-size slide

  6. Ⱖ㻜尝剤齡랃㔮ꨈ

    View full-size slide

  7. 1ZUIPO
    ˖ 䎃ⴀ植涸玑䒭铃鎊
    ˖ չ㢵ꅾⰩ眕պNVMUJQBSBEJHN

    ̔搂锸㋐姹➊랃괐呔鿪腋♳䩛 ٥Ī٥

    ˖ ぐ䎂〵♳鿪腋⢪欽罜⚂♶꨾銴管陼

    View full-size slide

  8. 䪪ⵌ1ZUIPO
    0494QPUMJHIU̔穅畮堥
    -JOVY$USM"MU5鋕涮遤晝罜㹁
    8JOEPXT䖰QZUIPOPSH♴鯺*%-&

    View full-size slide

  9. 䩧⦐䬸ㄎゅ

    View full-size slide

  10. QSJOU ㍜⚆歲

    デ鏰1ZUIPO䧮⦛銴⨞➊랃
    鸏酭僽⽫ⴀ匌銯⢵
    䭍䓞剚䪾䨾剤銴⴪ⴀ⢵涸须鎝⺫⡞
    㽠⫹㖈㻨俒畎♧垺
    ꧱䒸贫デ鏰1ZUIPO鸏僽♧媯俒㶶
    ㋲䒸贫⛳〳⟃欽

    View full-size slide

  11. 䬄⦐✥侸

    View full-size slide

  12. JNQPSUSBOEPN
    锞㢫꬗涸玑䒭
    㸤䧭♧❉䧮⦛♶剚涸⸆腋
    䧮⦛銴䪪涸㢫鿈玑䒭僽չSBOEPNպ

    View full-size slide

  13. SBOEPNSBOEJOU

    չ涸պ
    SBOEPNJOUFHFS涸簮㻨
    鸏⦐ⴅ䒭剚欴欰➝倴窍㹁眕㕠Ⰹ涸侮侸
    ⶍⶍ⻽Ⰵ涸չrandomպ
    䖰ⵌ

    View full-size slide

  14. 贖椚须俲

    View full-size slide

  15. SFTUBVSBOUT<崞㣐荈⸔귭 ˘>
    騈侸㷸♳涸չ湱瘞պ♶♧垺
    鸏酭僽չ䭸崣պ涸䠑䙼
    倰䭍䓞デ鏰1ZUIPO鸏僽♧⦐ꤏ⴪
    㹁纏♧⦐そ㶶
    鸏酭僽չ귭䑼⦛պ
    酭꬗〳⟃㶸佞
    ♶姺♧媯俒㶶

    View full-size slide

  16. 玖⡲⥜佖

    View full-size slide

  17. SFTUBVSBOUTBQQFOE 뛩뒊㼭♬

    !
    SFTUBVSBOUT<㼭犷 〵猰㣐>
    植㖈restaurants酭꬗僽⦐ꤏ⴪涸չ暟⟝պ
    䧮⦛〳⟃銴ꤏ⴪꣡⸈♧媯俒㶶ⵌ剓㽵畮
    殹搭⛳〳⟃♧妄꣡⸈㥪㢵媯a = a + b ! a += b

    View full-size slide

  18. SFTUBVSBOUT<>
    !
    MFO SFTUBVSBOUT

    ⛳〳⟃欽程䒸管贫《⧩䖰Ꟛ㨥侸
    《䖤ꤏ⴪涸Ꟁ䏞

    View full-size slide

  19. ⢵䬄佅硹ゅ

    View full-size slide

  20. Ⱖ㻜剤럊㣐勞㼭欽✫
    ⢵⹛럊1ZUIPO涸溫呔

    View full-size slide

  21. GSPNVSMMJCSFRVFTUJNQPSUVSMPQFO
    㥶卓僽1ZUIPO銴⻽Ⰵ涸僽VSMMJC

    View full-size slide

  22. VSMPQFO IUUQHPPHMFDPN
    SFBE

    䩧Ꟛ笪㖧63-
    鿈隡ⴀ⢵

    View full-size slide

  23. 植㖈⡹剚鸮笪畀✫9%

    View full-size slide

  24. չ䧮銴䙦랃濼麥
    剤ㆭ❉⸆腋〳⟃欽պ

    View full-size slide

  25. 垸穉 NPEVMFT

    ˖ Ⰹ䒊涸垸穉〳⟃䖰1ZUIPO

    㸽倰笪畀叆鑉ⵌ
    • ˤ٨̨╹೿ม PyPI ୷⪑ơ

    㡠[sudo] pip install …㡡
    • ˤ٨̨╹೿Хơ

    㡠ʫϪ⳻ቛ৫࿡ዅʫϪᗃᐲ㡤
    Ӱவ௡ዅʫϪᕻ⊓㡡

    View full-size slide

  26. ㄤ$涸㼩嫲

    View full-size slide

  27. #include
    using namespace std;
    !
    int main(int argc, char* argv)
    {
    cout << “Hi NTUOSC!”;
    return 0;
    }
    print(“Hi NTUOSC!”)
    $ 1ZUIPO
    Ⱖ㻜♧遤㽠腋邍麨幢嘽
    玑䒭銴⨞➊랃✫
    騈1ZUIPO涸print()䠑䙼僽湱ず涸

    View full-size slide

  28. string a = “ݙ”;

    string b = “”;
    for (int i = 1; i <= 5; i++)
    {
    b += a;
    }
    cout << b;
    print(“ݙ” * 5)
    $ 1ZUIPO
    俒㶶銴隶❀⦔
    湬䱺⛨⟃㽠㥪✫
    ♶䗳駵㔐⿡书ꚽ瀖

    View full-size slide

  29. for (int i = 1; i <= 5; i++)
    {
    cout << “#” << i << “\n”;
    }
    for i in range(5):
    print(“#” + str(i))
    $ 1ZUIPO
    鎹䖤銴欽瑠呔簮䱖ㆦ

    View full-size slide

  30. 㥪欽涸垸穉⦛
    莊䎙⦐玑䒭⚥䌢欽涸⢿㶩

    View full-size slide

  31. JNQPSUCBTF
    CBTFCFODPEF Ꟛ彂爢FODPEF


    剤莇馱涸鑨〳⟃(PPHMF♧♴
    㸐腋䪾⟤⡦须俲鱲䧭〳곏爚涸俒㶶
    ⯓管焺䧭✳鹎⡙呔䒭

    View full-size slide

  32. JNQPSUSF
    SFNBUDI =E=E

    鸏僽姻鋊邍麨䒭♴妄剚➝稲㸐
    鸒䌢欽⢵嫲㼩俒㶶呔䒭
    ⛳僽ⴕ區笪갤Ⰹ㺂涸㥪䍲䩛

    View full-size slide

  33. JNQPSUTNUQMJC
    DMJFOUTNUQMJC4.51@44- 

    NBJMOUVFEVUX port=

    DMJFOUTFOENBJM 

    䖎㢵➃鿪♶濼麥
    Ⱖ㻜〫銴♲遤玑䒭㽠〳⟃㺕♧㼓FNBJM

    View full-size slide

  34. ♴妄铭玑
    ˖ ❀儻♳♬럊
    ˖ 鎙⚥來㹔
    ˖ 姹鵔♳〵ⴕ❧'SFF5BML
    ˖ 铭玑稇勞剚䓹顦㖈荩㣐Ꟛ彂爢纈穉莅)BDLQBE

    View full-size slide

  35. 2VFTUJPOT
    鎹䖤㞅Ⰵ爢邍㋲㋅PXP

    View full-size slide