ブール型(bool

trueまたはfalseのどちらかであるブールオブジェクト

によって返される

ブールオブジェクトは、次の関数とメソッドによって返されます。

ブールメソッド

bool.to_int()

trueの場合1を返し、falseの場合に0を返す

署名

int to_int()


bool.to_string()

ブール値がtrueの場合、文字列「true」を返します。 falseの場合は、「false」を返します。また、2つの文字列を位置引数として渡して、true/falseで何を返すかを指定することもできます。たとえば、bool.to_string('yes', 'no')は、ブール値がtrueの場合に「yes」を返し、falseの場合に「no」を返します。

署名

# Returns the string `'true'` if the boolean is true or `'false'` otherwise
str to_string(
  str [true_str],    # The string to return when the boolean is `true`
  str [false_str],   # The string to return when the boolean is `false`
)

引数

bool.to_string()メソッドは次の位置引数を受け付けます。

名前 説明 タグ
true_str str

ブール値がtrueの場合に返す文字列

[オプション]

デフォルト='true'

false_str str

str

[オプション]

ブール値がfalseの場合に返す文字列


デフォルト='false'

法的ページにウェブサイトのライセンス情報があります。