Check if object is a number or boolean

后端 未结 7 1058
攒了一身酷
攒了一身酷 2021-02-06 20:42

Design a logical expression equivalent to the following statement:

x is a list of three or five elements, the second element of which is

7条回答
  •  爱一瞬间的悲伤
    2021-02-06 21:15

    Python 2

    import types
    
    x = False
    print(type(x) == types.BooleanType) # True
    

    Python 3

    # No need to import types module
    x = False
    print(type(x) == bool) # True
    

提交回复
热议问题