【发布时间】:2021-05-20 01:51:12
【问题描述】:
我正在尝试构建一个 dpy 命令,我可以在其中获取一个字符串,例如“Tomorrow at 6pm do the dishes”,然后获取一个日期时间对象和一个字符串。
我可以轻松地将所有内容转换为 dpy 的自定义转换器,我只需要一些帮助来解析字符串。有点像这样(不是真正的代码示例):
@bot.command()
async def remind(ctx, *, when: TimeConverter):
print(when.reason)
print(when.datetime)
!remind 6h do the dishes
!remind two days do the dishes
我找到了一个名为dateparser 的库,它将人类可读的时间转换为日期时间,但它无法处理我想要的。我该怎么做这样的事情?
【问题讨论】:
-
什么是“人类可读时间”?
-
您是否看到您链接的
dateparser有一个search?
标签: python datetime discord.py date-parsing