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 库去查找,但是有些方法定义的位置找不到。
网友评论