python

Mountain Lionにしてvimでpython書こうとしたらなんか怒られた話

以下で解決した. https://gist.github.com/3186381includeのpathが変わっててpyconfig.hが読めないよーということかな? sudo mkdir -p /usr/include/python2.7 sudo ln -s /System/Library/Frameworks/Python.framework/Versions/Current/include/python2.…

転置行列

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,…

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…

Cluster3.0(Pycluster)導入

1,Cluster3.0のページへ2,Cluster3.0をダウンロード → インストール 3,Pyclusterをダウンロード → インストール 4,Numpyが入ってないと怒られるのでダウンロード →(ry 5,インポート from Pycluster import *

set()楽しい

a = [1, 2, 3, 4, 5] b = [1, 2, 6, 7, 8] print set(a) print set(b) print set(a+b) print set(a+b) - set(a) print set(a+b) - set(b) print [i for i in (set(a+b) - set(a))] + [i for i in (set(a+b) - set(b))] print set([i for i in (set(a+b) - se…