关于__name__和__main__

__name__:表示模块,类等的名字;

__main__:模块,xxx.py文件本身:

  • 被直接执行时,对应的模块名就是__main__了
    • 可以在
    • if __name__ == “__main__”:
    • 中添加你自己想要的,用于测试模块,演示模块用法等代码。
  • 作为模块,被别的Python程序导入(import)时,模块名就是本身文件名xxx了。

 

posted @ 2017-08-25 15:15  云中摆渡的老船长  阅读(141)  评论(0)    收藏  举报

It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things