我正在尝试使用import模块和getattr获取类方法的docstring。我以前做过以下工作:
getattr(import_module('string'),'capwords').__doc__
哪一个像预期的那样有效? 现在我尝试对类方法执行相同的操作,并以this为例
getattr(import_module('string','Formatter'),'format').__doc__
我得到以下错误
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'format'
如何获取类方法的doc字符串。你知道吗
感觉你在努力
或者
要获取^{} 方法的docstring,可以执行以下操作:
相关问题 更多 >
编程相关推荐