Python学习之——Python的基本数据类型

#在Python中0为False,1为True
>>> int(False)
0
#
>>> int(True)
1
>>> bool(1)
True
>>> bool(0)
False

#非空则为True
>>> bool(2)
True
>>> bool(2.2)
True
>>> bool(-1)
True
>>> bool(0)
False
>>> bool('abc')
True
>>> bool('')
False
>>> bool([1,2,3])
True
>>> bool([])
False
>>> bool({1,1,1})
True
>>> bool({})
False

#这是一个复数,使用场景较少
>>> 36j
36j
posted @ 2019-05-12 14:22  xiangwb  阅读(91)  评论(0编辑  收藏  举报