代码点读机 / Python / __file__

__file__ Python · 特殊属性

模块对象里的当前文件路径。

怎么用

模块.__file__

小例子

import os
print(os.__file__)

说明

os 模块文件的路径

官方文档:https://docs.python.org/zh-cn/3/reference/import.html

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条