2005-04-07から1日間の記事一覧

便利なhelp(変数の型を調べる)

>>> a = 10 >>> type(a) >>> a = "test" >>> type(a) >>> a = [1, 2, 3] >>> type(a) >>> a = (1, 2, 3) >>> type(a) >>> a = {1:1, 2:2, 3:3} >>> type(a) >>> def b(): print "test" >>> a = b >>> type(a) >>> import urllib >>> a = urllib >>> type(a) …

便利なhelp2(メソッド一覧取得)

メソッドがわからな〜いってときはdir() >>> import urllib >>> x = urllib.urlopen("http://www.google.ne.jp") >>> dir(x) ['__doc__', '__init__', '__iter__', '__module__', '__repr__', 'close', 'fileno', 'fp', 'geturl', 'headers', 'info', 'next'…

便利なhelp(モジュールのヘルプ)

対話モードの時、import したモジュールのヘルプが見れる。 >>>import string >>>help(string) でモジュールのヘルプが表示される。(英語だけど...)