Python 内建函数 - bool([x])

    xiaoxiao2021-03-25  74

    Manual直译实例拓展阅读

    Manual

    Return a Boolean value, i.e. one of True or False. x is converted using the standardtruth testing procedure. Ifx is false or omitted, this returnsFalse; otherwise it returnsTrue. The bool class is a subclass ofint . It cannot be subclassed further. Its only instances areFalse and True.

    直译

    返回一个布尔值,例如True 或 False之一。‘x’通过使用标准的真值检测程序(好搞siao)— truth testing procedure。如果’x’为否或省略,则返回False;否则返回True。bool类是int子类,它不能进一步划分子类,且仅具有False和True实例。

    实例

    >>> bool([0]) True >>> bool([1]) True >>> bool([False]) True >>> bool([]) False >>> bool(['']) True >>> bool(()) False >>> bool({}) False >>> bool((False)) False

    拓展阅读

    真值检测程序(Truth Testing Procedure) 数值类型(Numeric Type)- 整数(int)、浮点数(float)、复数(complex)

    转载请注明原文地址: https://ju.6miu.com/read-38677.html

    最新回复(0)