if __name__ == '__main__' 如何正確理解

__name__ 是當前模塊名,當模塊被直接運行時模塊名爲 __main__ 。這句話的意思就是,當模塊被直接運行時,如下代碼塊將被運行,當模塊是被導入時,代碼塊不被運行。python __main__app '__main__' is the name of the scope in which top-level code executes. A module’s __name__ is se
相關文章
相關標籤/搜索