import a_module
print a_module.__file__


上述代码将范围 .pyc 文件被加载的路径,如果需要跨平台解决方案,可用下面代码:

import os
path = os.path.dirname(amodule.__file__)

相关文章:

  • 2021-12-25
  • 2021-11-25
  • 2022-12-23
  • 2022-02-15
  • 2021-07-04
  • 2021-06-30
  • 2022-12-23
  • 2021-09-02
猜你喜欢
  • 2021-08-12
  • 2021-12-26
  • 2021-11-23
  • 2021-11-04
  • 2022-01-25
相关资源
相似解决方案