python - 从函数中获取文档字符串

我有以下功能:

def my_func():
    """My docstring is both funny and informative"""
    pass

如何访问文档字符串?

最佳答案

交互方式,你可以用

help(my_func)

或者你可以从代码中检索它

my_func.__doc__

https://stackoverflow.com/questions/713138/

相关文章:

linux - dd:如何计算最佳 block 大小?

linux - 如何在命令行中从脚本运行函数?

python - 尽管我调用了 pyplot.show(),但 matplotlib 没有显示我的情

c - 如何在 C 中与 Linux 一起使用共享内存

python - 根据数据类型获取 pandas 数据框列的列表

python - 减少matplotlib图中的左右边距

python - 从 Pandas 日期时间列中分别提取月份和年份

python - 获取 MAC 地址

linux - Linux bash 中波浪号的含义(不是主目录)

linux - 附加到进程输出以供查看