- Inspect: python标准库
import inspect
from bs4 import BeautifulSoup
inspect.detdoc(BeautifulSoup) # 查看文档
inspect.getsourcefile(BeautifulSoup) # 查看路径
inspect.getsourcelines(BeautifulSoup) # 查看源代码
- Dill: 第三方库
import dill
dill.source.getsourcefile(BeautifulSoup) # 获取源代码路径
dill.source.getsourcelines(BeautifulSoup) # 获取源代码
dill.source.findsource(BeautifulSoup)
- IDE
使用pycharm ctrl+click可以直接跳转到源代码