#文件名为test_file.py print("哈哈") if __name__ == '__main__': print("嘎嘎")
输出结果: 哈哈 嘎嘎 把test_file.py做为模块导到其它目录 #文件名为my_file.py import test 输出结果:哈哈