【Python】如何找到库中方法定义的位置
2024-08-15 本文已影响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 库去查找,但是有些方法定义的位置找不到。