__name__ == '__main__' usage

Popular understanding the __name__ == '__main__' :

If you called the Little Ming .py, in the eyes of friends, you are the Xiao Ming (__name__ == 'Bob'); in your own eyes, you are your own (__name__ == '__main__').

if __name__ == '__main__' means: when the file is run directly .py time, if __name__ == block '__main__' will be run under; .py files when introduced in modular form, if __name__ = = code block '__main__' is not under operation.

Guess you like

Origin www.cnblogs.com/YINBin/p/11126705.html