Python 有可能得到协同程序的治疗吗?
我得到了一个定义如下的函数:Python 有可能得到协同程序的治疗吗?,python,discord.py,docstring,Python,Discord.py,Docstring,我得到了一个定义如下的函数: @bot.command() 异步定义ping(ctx): """ 回程乒乓球 """ 等待ctx发送(“pong!”) 但我会接受它的修改,以获得比discord模块更好的功能帮助。我怎么能有文档串 我试过: __doc__ ( inside ping function ) ping.__doc__ 从中可以看出,您的func被包装在命令对象中: def command(name=None, cls=None, **attrs): """..."""
@bot.command()
异步定义ping(ctx):
"""
回程乒乓球
"""
等待ctx发送(“pong!”)
但我会接受它的修改,以获得比discord模块更好的功能帮助。我怎么能有文档串
我试过:
__doc__ ( inside ping function )
ping.__doc__
从中可以看出,您的func
被包装在命令
对象中:
def command(name=None, cls=None, **attrs):
"""..."""
if cls is None:
cls = Command
def decorator(func):
if isinstance(func, Command):
raise TypeError('Callback is already a command.')
return cls(func, name=name, **attrs)
return decorator
该装饰器的docstring声明:
默认情况下,help
属性自动从
函数的docstring,并使用
inspect.cleandoc
。如果docstring是字节
,则会对其进行解码
使用utf-8编码进入str
您可以在中看到这种情况,因此您应该能够通过ping查看您的docstring。help
您可以从中看到您的func
包装在命令
对象中:
def command(name=None, cls=None, **attrs):
"""..."""
if cls is None:
cls = Command
def decorator(func):
if isinstance(func, Command):
raise TypeError('Callback is already a command.')
return cls(func, name=name, **attrs)
return decorator
该装饰器的docstring声明:
默认情况下,help
属性自动从
函数的docstring,并使用
inspect.cleandoc
。如果docstring是字节
,则会对其进行解码
使用utf-8编码进入str
您可以在中看到这种情况,因此您应该能够通过
ping.help
ping查看您的docstring。如果@bot.command()
装饰程序运行良好,则\uuu doc\uuu
应该可以工作。如果我尝试在func之外,则返回@bot.commandping的文档。如果@bot.command(),则\uu doc\uu应该可以工作
decorator运行良好。如果我尝试在func之外运行,它会将@bot.command的文档返回给我