Export to GitHub

openbookproject - issue #896

[LovPy] PCS101 布尔类型


Posted on Sep 23, 2008 by Massive Giraffe

现在内容: >>> bigornot = 1>2 >>> bigornot False

建议修订为: >>> bigornot = 1>2 >>> bigornot False >>> if []:print 'True' ... else: print 'False' ... False >>> if '':print 'True' ... else: print 'False' ... False

理由: 通过添加其他例子,可以加深对“在Python中,None、任何数值类型中的0、空字符串 ''、空元组()、空列表[]、空字典{}都被当作False”的理解。

Comment #1

Posted on Sep 23, 2008 by Grumpy Dog

(No comment was entered for this change.)

Comment #2

Posted on Sep 23, 2008 by Grumpy Dog

r1626 最终改为:

bigornot = 1>2 bigornot False if []: ... print "True" ... else: ... print "False" ... False if '': ... print "True" ... else: ... print "False" ... False

多谢补充~

Status: Fixed

Labels:
Type-Enhancement Priority-Medium Component-LovePy