SlideShare a Scribd company logo
Python 入門から Python-Twitter 利用のハンズオン FukPUG Workshop vol.0 2012-01-29
お前、誰よ? Name : Yukitaka Uchikoshi job :  結婚式場で社内 SE id: uchikoshi22 level : Python 初心者クラス
今日の目標 Hello World から twitter の API 利用 Hello World 名前で呼んでみよう 群れをなそう 反復動作で楽をしよう 人生とは選択の連続である 魔法のランプを作ろう twitter のタイムラインを取得しよう
1. Hello World
$ python >>> “Hello World” ??? >>> print “Hello World” ??? >>> exit()
2.  名前で呼んでみよう
>>> event = “Python 勉強会” >>> print event ??? >>> place = “@AipCafe” >>> title = event + place >>> print title ???
>>> name = “uchikoshi” >>> number = 22 >>> id = name + number See what's gonna happen. And Fix it >>> print id ???
3.  群れをなそう
>>> lang = [“Python”, “Ruby”,] >>> print lang[1] ??? >>> lang.append(“Perl”) >>> print lang[2] ???
>>> lang[2] = “Java” >>> print lang[2] ??? >>> lang.append(“ なでしこ” ) >>> lang.append(20120129) Think if the last 2 lines are correct
>>> fw = {“django”: “python”,  “ rails”: “ruby”, “ catalyst”: “cisco”} >>> print fw[“python”] ??? >>> fw[“catalyst”] = “perl” >>> fw[“play”] = “java” >>> print fw ???
4.  反復動作で楽をしよう
>>> print 0 >>> print 1 >>> print 2 >>> print 3 >>> print 4 >>> print 5 >>> print 6 >>> print 7 >>> print 8 >>> print 9 >>> print 10
>>> for i in [0, 1, 2, 3, 4, 5]: .  .  .  print i .  .  . ??? >>> for la in lang: .  .  .  prnt la .  .  . ???
5.  人生とは選択の連続である
>>> for i in range(1, 100): .  .  .  if i % 2 == 0: .  .  .  print i .  .  .  else: .  .  .  continue .  .  . ???
>>> lang = [“python”, “ruby”, “perl”] >>> for la in lang: .  .  .  if la == “python”: .  .  .  print “use django” .  .  .  elif la == “ruby”: .  .  .  print “use rails” .  .  .  else: .  .  .  print “Learn Ruby” .  .  .
6.  魔法のランプを作ろう
>>> def gae_fw(): .  .  .  return “kay” .  .  . >>> fw = gae_fw() ??? >>> def web_fw(): .  .  .  return “django”, “flask” .  .  . >>> fw0, fw1 = web_fw() >>> print fw0, “,”, fw1 ???
ナベアツ関数
>>> def nabeatsu(n): .  .  .  if n % 3 == 0: .  .  .  return True .  .  .  elif “3” in str(i): .  .  .  return True  .  .  .  else: .  .  .  return  str(n) .  .  . >>> for i in range(1, 100): .  .  .  if nabeatsu(i): .  .  .  print i, “!!!” .  .  .  else: .  .  .  print I .  .  .  ???
7.  Twitter のタイムラインを 取得しよう
python-twitter の導入 twitter.py をソースコードと同じディレクトリにコピー pip で自動インストール ソースコンパイル apt や yum でインストール
twitter.py をダウンロード 口頭で説明します! http://code.google.com/p/python-twitter/ のソースを改変したものです。 (通常は pip でのインストールを推奨します)
次のコードを twitter.py と同じディレクトリに保存してください。 #!/usr/bin/env python import twitter api = twitter.Api() statuses = api.GetUserTimeline(id='uchikoshi22', count=2) for s in statuses: print s.text
http://www.python.jp/doc/release/tutorial/index.html 参考書籍
Python チュートリアル http://www.python.jp/doc/release/tutorial/index.html PEP8 – Style Guide for Python Code http://oldriver.org/python/pep-0008j.html Google Python スタイルガイド http://works.surgo.jp/translation/pyguide.html 参考 URL
The Zen of Python $python >>>  import this
FukPUG ではハンズオン講師を 募集しています これからもよろしくお願いします

More Related Content

PPT
Python twitterとtkinterのことはじめ
PDF
「Python言語」はじめの一歩 / First step of Python
PDF
「Python言語」はじめの一歩 / First step of Python / 2016 Jan 12
PPTX
2017/12/21 虎の穴 Python勉強会
PDF
python-twitterを用いたTwitterデータ収集
PDF
今年使ってみて良かった、Pythonモジュール、パッケージ、ツール
PDF
久しぶりのPythonでgoogleのアレを制御してみた
PDF
第1回python勉強会
Python twitterとtkinterのことはじめ
「Python言語」はじめの一歩 / First step of Python
「Python言語」はじめの一歩 / First step of Python / 2016 Jan 12
2017/12/21 虎の穴 Python勉強会
python-twitterを用いたTwitterデータ収集
今年使ってみて良かった、Pythonモジュール、パッケージ、ツール
久しぶりのPythonでgoogleのアレを制御してみた
第1回python勉強会

What's hot (19)

PDF
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
PDF
Python入門
PDF
XML-RPC : Pythonが「電池付属」と呼ばれる理由
PPTX
Apilecture for 2014/02/22 at shannonlab
PDF
Python Kyoto study
PDF
20170131 python3 6 PEP526
PDF
Python パッケージの影響を歴史から理解してみよう!
PDF
Pythonを取り巻く開発環境 #pyconjp
PDF
Python Kyoto study LT
PDF
Pythonでゲーム作る
PDF
PEP8を読んでみよう
PDF
Python3 プログラミング勉強会
PDF
Python 2/3コード共存戦略 #osakapy
POTX
素振りのススメ at Python入門者の集い
PDF
Elog and Ebuild Phase Hook
PPTX
各OSにおいて、OpenCVをpythonから使う方法
PDF
オープンCAEとPython
ODP
Introduction of Python
PDF
Vsubuntu
PyCon2020 Pythonで競プロをしよう! 〜入門者が知っておくべき高速化Tips〜
Python入門
XML-RPC : Pythonが「電池付属」と呼ばれる理由
Apilecture for 2014/02/22 at shannonlab
Python Kyoto study
20170131 python3 6 PEP526
Python パッケージの影響を歴史から理解してみよう!
Pythonを取り巻く開発環境 #pyconjp
Python Kyoto study LT
Pythonでゲーム作る
PEP8を読んでみよう
Python3 プログラミング勉強会
Python 2/3コード共存戦略 #osakapy
素振りのススメ at Python入門者の集い
Elog and Ebuild Phase Hook
各OSにおいて、OpenCVをpythonから使う方法
オープンCAEとPython
Introduction of Python
Vsubuntu
Ad

Similar to Python入門からpython twitter利用のハンズオン (20)

KEY
Hello World Python featuring GAE
KEY
ひのきのぼうだけで全クリ目指す
PDF
Nseg15 一般的じゃないpython入門
PDF
おまえらこのライブラリ使ってないの? m9 (2013-07)
PDF
明日からはじめるネットワーク運用自動化
PPTX
【プログラミング教室】テキスト
PDF
PyPy 紹介
PPTX
rpi_handson_2.5
PDF
DATUM STUDIO PyCon2016 Turorial
PDF
Flask勉強会その1
PDF
S03 t1 python_learningdiary#3
PDF
Pythonで始めるDropboxAPI
PPTX
Django_Fukuoka
PDF
Django_fukuoka
PDF
LLdeade Python Language Update
PDF
はじめてのPython
PDF
入門書を読み終わったらなにしよう? 〜Python と WebAPI の使い方から学ぶ次の一歩〜 / next-step-python-programing
PDF
新しくプログラミング言語・・・Rubyでやってみた
ODP
Lt会01_uetch
PDF
使えるDjango1.4
Hello World Python featuring GAE
ひのきのぼうだけで全クリ目指す
Nseg15 一般的じゃないpython入門
おまえらこのライブラリ使ってないの? m9 (2013-07)
明日からはじめるネットワーク運用自動化
【プログラミング教室】テキスト
PyPy 紹介
rpi_handson_2.5
DATUM STUDIO PyCon2016 Turorial
Flask勉強会その1
S03 t1 python_learningdiary#3
Pythonで始めるDropboxAPI
Django_Fukuoka
Django_fukuoka
LLdeade Python Language Update
はじめてのPython
入門書を読み終わったらなにしよう? 〜Python と WebAPI の使い方から学ぶ次の一歩〜 / next-step-python-programing
新しくプログラミング言語・・・Rubyでやってみた
Lt会01_uetch
使えるDjango1.4
Ad

Python入門からpython twitter利用のハンズオン