転置行列
a = [range(10), range(11,20), range(21,30)] b = map(list, zip(*a)) print a print b
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [11, 12, 13, 14, 15, 16, 17, 18, 19], [21, 22, 23, 24, 25, 26, 27, 28, 29]] [[0, 11, 21], [1, 12, 22], [2, 13, 23], [3, 14, 24], [4, 15, 25], [5, 16, 26], [6, 17, 27], [7, 18, 28], [8, 19, 29]]
おっかないですね.
githug level14で詰まった
詰まったのでメモ
こちらを見て解決しました.
https://github.com/Gazler/githug/issues/70
要するに.gitignoreを作る課題のところで.gitignore自体はすでに中身付きで存在するので,
echo *.swp > .gitignore
とかやっちゃうともともとの中身が消えちゃうってうまく行かなくなるとのこと.
.gitignoreの中を
.profile.yml .gitignore *.swp
になおして
githug reset
して再度level14に臨んで見ましょう.
tweepy使用,public streamを垂れ流す
#coding:utf-8 import tweepy import sys consumer_key = '' consumer_secret = '' access_key = '' access_secret = '' class StreamListener(tweepy.StreamListener): def on_status(self, status): if sys.argv[1].decode('utf-8') in status.text: print (status.user.screen_name+' : '+status.text.encode('utf-8')) auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) stream = tweepy.Stream(auth, StreamListener()) stream.sample()
コピペですが.
http://newbienewbie.wordpress.com/2011/04/16/twitterのstreaming-apiを試してみる/
スクリプトに引数として単語を渡すとそれを含むtweetをpublic streamから拾ってくる.