相关疑难解决方法(0)

如何从函数本身内部打印python函数的Docstring?

我想从函数本身内部打印python函数的docstring.例如.

def my_function(self):
  """Doc string for my function."""
  # print the Docstring here.
Run Code Online (Sandbox Code Playgroud)

目前我my_function在定义之后直接这样做.

print my_function.__doc__
Run Code Online (Sandbox Code Playgroud)

但宁愿让函数自己这样做.

我已经打过电话print self.__doc__ print self.my_function.__doc__和print this.__doc__内部创建my_function但这并没有工作.

python printing docstring function

61
推荐指数
4
解决办法
6万
查看次数

标签 统计

docstring ×1

function ×1

printing ×1

python ×1