美文网首页
【Python】如何找到库中方法定义的位置

【Python】如何找到库中方法定义的位置

作者: 盐果儿 | 来源:发表于2024-08-15 17:44 被阅读0次

import inspect

import numpy as np

# 获取方法定义的源代码和位置

source_code = inspect.getsource(np.array)

file_location = inspect.getfile(np.array)

print("Source Code:")print(source_code)

print(f"Defined in: {file_location}")

可以使用 inspect 库去查找,但是有些方法定义的位置找不到。

相关文章

网友评论

      本文标题:【Python】如何找到库中方法定义的位置

      本文链接:https://www.haomeiwen.com/subject/hlbekjtx.html