在python 判斷陳述句中 None, False, 空字串"", 0, 空串列[], 空字典{}, 空元組()都相當于 False
not None == not False == not '' == not 0 == not [] == not {} == not ()
需要注意的是'0'這個進行判斷回傳的是true
def test(val): if not val: print 'not' else: print 'yes' test(0) test(None) test('0') if not 0: print 1111
回傳
not not yes 1111
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/196581.html
標籤:Python
上一篇:自學python筆記(一)
