Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.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 discord.ext.commands.errors.CommandInvokeError:Command引发异常:AttributeError:“Command”对象没有属性“strftime”_Python_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python discord.ext.commands.errors.CommandInvokeError:Command引发异常:AttributeError:“Command”对象没有属性“strftime”

Python discord.ext.commands.errors.CommandInvokeError:Command引发异常:AttributeError:“Command”对象没有属性“strftime”,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,我试图做一个机器人命令,你可以问机器人是否是周三,但我一直得到这个错误,我不知道该怎么办。请帮忙。 这是我的代码: @client.command(aliases=['wednesdaymydudes', 'wednesday', 'wednesdaycheck'], pass_context=True) async def isitwednesdaymydudes(ctx): currentday = time.strftime('%A') if

我试图做一个机器人命令,你可以问机器人是否是周三,但我一直得到这个错误,我不知道该怎么办。请帮忙。 这是我的代码:

@client.command(aliases=['wednesdaymydudes', 'wednesday', 'wednesdaycheck'],
                pass_context=True)
async def isitwednesdaymydudes(ctx):
    currentday = time.strftime('%A')
    if currentday == 'Wednesday':
        await ctx.send('It is Wednesday, {}'.format(ctx.message.author.mention))
    else:
        await ctx.send('It is not Wednesday, {}'.format(ctx.message.author.mention))

为了得到一周中的某一天,你应该做的是

from datetime import datetime as dt

day = dt.now()

day_of_week = day.strftime('%A')

是否有另一个函数名为time的命令?它看起来像是有其他东西以该名称隐藏了Python模块,或者您没有导入它。