Python repr() 関数

Python 内置函数Python 組み込み関数


説明

repr() 関数はオブジェクトをインタープリタが読み取れる形式に変換します。

構文

以下は repr() メソッドの構文です:

repr(object)

パラメータ

  • object -- オブジェクト。

戻り値

オブジェクトの string 形式を返します。


実例

以下は repr() メソッドを使用した例です:

>>> s = 'サンプル'
>>> repr(s)
"'サンプル'"
>>> dict = {'サンプル': 'example.com', 'google': 'google.com'};
>>> repr(dict)
"{'google': 'google.com', 'サンプル': 'example.com'}"
>>>

Python 内置函数Python 組み込み関数

その他の拡張