1 import a_module2 print a_module.__file__上述代码将范围 .pyc 文件被加载的路径,如果需要跨平台解决方案,可用下面代码:1 import os2 path =os.path.dirname(amodule.__file__)