Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有可能得到协同程序的治疗吗?_Python_Discord.py_Docstring - Fatal编程技术网

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.command
ping的文档。如果
@bot.command(),则\uu doc\uu应该可以工作
decorator运行良好。如果我尝试在func之外运行,它会将@bot.command的文档返回给我