【问题标题】:Where are python modules stored?python模块存储在哪里?
【发布时间】:2015-09-30 19:08:16
【问题描述】:

我是新手,我想知道,您可以在我的计算机上导入的模块、包和内容的所有代码在哪里。

谁能给我一个简短的课程并帮助我?

【问题讨论】:

标签: python module


【解决方案1】:

假设您想知道xyz 模块的位置。你在解释器上这样做

>>> import xyx
>>> xyz.__file__

您将从导入模块的位置获得 pyc 文件的位置。

你也可以这样做

>>> xyz

获取模块名称​​和模块的位置。

要了解所有模块导入的可能位置,请使用sys.path

>>> import sys
>>> sys.path

当您执行import 时,这将为您提供 Python 搜索模块的位置列表。

希望对您有所帮助。

【讨论】:

  • 回溯(最近一次调用最后一次):文件“”,第 1 行,在 sys._file_ AttributeError: 'module' object has no attribute 'file'
  • 文件周围的双下划线。你已经放单了。
猜你喜欢
  • 1970-01-01
  • 2018-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-29
  • 1970-01-01
相关资源
最近更新 更多