Python中 if not 用法


not與邏輯判斷句if連用,代表not后面的表達式為False的時候,執行冒號后面的語句。比如:
a = False
if not a:   (這里因為a是False,所以not a就是True)
    print "hello"

這里就能夠輸出結果hello

a = None同理

 

原文鏈接:https://blog.csdn.net/m0_37843198/article/details/78890523?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM