servermodel/addons/__init__.py
userName ba8e5ee95a lqs
2024-08-25 04:20:21 +00:00

15 lines
766 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pkgutil
import os.path
__path__ = [
os.path.abspath(path)
for path in pkgutil.extend_path(__path__, __name__)
]
#import pkgutil: 导入 Python 的标准库模块 pkgutil用于处理包。
# import os.path: 导入 os.path 模块,用于处理文件路径。
# 路径扩展:
# pkgutil.extend_path(__path__, __name__): 这个方法会根据当前模块的 __path__ 和模块名称 (__name__) 扩展出更多的路径。这些路径通常是指向包内的其他文件或子目录。
# 转换为绝对路径:
# 使用列表推导式遍历 pkgutil.extend_path(__path__, __name__) 返回的所有路径,并通过 os.path.abspath(path) 转换为绝对路径。
# 最终结果被赋值给 __path__这将覆盖原有的 __path__ 值。