python输出某个库的路径

 

 

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)

 

 

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

posted @ 2023-12-28 22:13  西北逍遥  阅读(31)  评论(0编辑  收藏  举报