
嫁ちゃん
組み込み関数にどんなメソッドがあるか知りたいんですけど?

わたし
組み込み関数の「dir()」で、メソッドの一覧を取得できるよ。
目次
はじめに
クラスに含まれるメソッドの一覧を取得します。
用法
dir([object])
引数がない場合、現在のローカルスコープにある名前のリストを返します。引数がある場合、そのオブジェクトの有効な属性のリストを返そうと試みます。
例
str型に含まれるメソッド一覧を表示するサンプル
(ここでは、’__’ が含まれるものは除くサンプルです。)
for x in dir(str):
if '__' not in x: print x
capitalize
casefold
center
count
encode
endswith
expandtabs
:::途中省略:::
startswith
strip
swapcase
title
translate
upper
zfill
おわりに

嫁ちゃん
メソッドの一覧が見れたね。

わたし
そうだね。
組み込み関数だけでなく、自分で作ったクラスのメソッドなども同じように一覧取得できるよ。Pythonの統合環境(IDE)を使っている人なら、入力補完で一覧表示されるから便利だね。
組み込み関数だけでなく、自分で作ったクラスのメソッドなども同じように一覧取得できるよ。Pythonの統合環境(IDE)を使っている人なら、入力補完で一覧表示されるから便利だね。
[A8_TechAcademy065]
[Footer]