https://blog.csdn.net/ace_fei/article/details/7762431
1 | import a_module |
2 | print a_module.__file__ |
上述代码将范围 .pyc 文件被加载的路径,如果需要跨平台解决方案,可用下面代码:
1 | import os |
2 | path = os.path.dirname(amodule.__file__) |
转自:http://www.oschina.net/question/149123_25377