Python str() 関数

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


説明

str() 関数はオブジェクトを人間が読みやすい形式に変換します。

構文

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

class str(object='')

パラメータ

  • object -- オブジェクト。

戻り値

オブジェクトの文字列形式を返します。


例

以下は str() メソッドの使用例です:

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

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

その他の拡張