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
相关文章
相关标签/搜索