从函数中获取文档字符串 [英] Getting the docstring from a function

查看:39
本文介绍了从函数中获取文档字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下功能:

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

如何访问文档字符串?

推荐答案

交互,可以用

help(my_func)

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

Or from code you can retrieve it with

my_func.__doc__

这篇关于从函数中获取文档字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆