if __name__ == '__main__'

2017-07-19  本文已影响0人  孔李聃丘

When the Python interpreter reads a source file, it executes all of the code found in it.

Before executing the code, it will define a few special variables. For example, if the python interpreter is running that module (the source file) as the main program, it sets the special name variable to have a value "main". If this file is being imported from another module, name will be set to the module's name.

see this page to get more

上一篇下一篇

猜你喜欢

热点阅读