# file one.py
def func():
    print("func() in one.py")

print("top-level in one.py")

if __name__ == "__main__":
    print("one.py is being run directly")
else:
    print("one.py is being imported into another module")

# file two.py
import one

print("top-level in two.py")
one.func()

if __name__ == "__main__":
    print("two.py is being run directly")
else:
    print("two.py is being imported into another module")

小明.py

朋友眼中你是小明(__name__ == '小明'),
你自己眼中你是你自己(__name__ == '__main__'),

你编程很好, 朋友调你去帮他写程序(import 小明, 这时你在朋友眼中: __name__ == '小明'),
但你晚上也会打开xx网站, 做一些自己的事情(直接运行小明.py, __name__ == '__main__')