【问题标题】:Is there a way for me to print dates with datetime as dd/mm/yyyy [duplicate]有没有办法让我打印日期时间为 dd/mm/yyyy 的日期 [重复]
【发布时间】:2023-03-29 17:49:01
【问题描述】:

我目前正在编写一个不和谐的机器人,我希望能够将今天的日期打印为 dd/mm/yyyy。我尝试了 .strftime().strpdate(),但我找不到合并 .now() 的方法。 p>

import time, datetime
from datetime import datetime

@commands.command()
async def date(self, ctx):
    await ctx.send(datetime.now().strpdate('%d:%m:%Y'))

这是输出:

discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'datetime.datetime'对象没有属性'strpdate'

【问题讨论】:

标签: python date datetime discord.py


【解决方案1】:
from datetime import datetime
datetime.now().strftime('%d:%m:%Y')
'06:07:2020'

【讨论】:

    猜你喜欢
    • 2016-07-31
    • 2017-07-20
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 2013-10-19
    • 2017-03-08
    • 2013-03-18
    • 1970-01-01
    相关资源
    最近更新 更多