日与月份参数未填写? (日期时间)
我试图弄清楚如何返回现在与今年最后一分钟之间的时间差。我似乎收到错误消息“参数‘日’未填充”和“参数‘月’未填充”。
from datetime import datetime
rn = datetime.now()
ny = datetime('2022, 12, 31, 23, 59')
df = ny - rn
print(df.total_seconds())
如果有人可以帮忙解决这个问题,我们将不胜感激!
I'm trying to figure out how to return the difference of time in between now and from the last minute of this year. I seem to be getting errors saying "Parameter 'day' unfilled" and "Parameter 'month' unfilled".
from datetime import datetime
rn = datetime.now()
ny = datetime('2022, 12, 31, 23, 59')
df = ny - rn
print(df.total_seconds())
if anyone could help out with this that would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用单个字符串作为参数,您必须使用
strptime
来解析该字符串,或者以其他方式从字符串中获取实际数字You used a single string as parameter, you'd have to either use
strptime
to parse the string, or otherwise get your actual numbers out of the string