import random import os #查看random模块的绝对路径 print(random.__file__) #查看os模块是否有__file__属性: [attr for attr in dir(os) if attr.startswith("__")] #输出结果中有__file__属性
python的内置属性__file__
原文:https://blog.51cto.com/13560219/2453696