python输出某个库的路径

发布时间 2023-12-28 22:15:04作者: 西北逍遥

 

 

import inspect
 
def get_module_path(module_name):
    module = __import__(module_name)
    file_path = inspect.getfile(module)
    return file_path
 
# 示例用法
module_path = get_module_path("os")
print(module_path)

 

 

####################