RobotFramework:日期格式转换问题
问题描述:
我不知道这里出了什么问题。我给了一个时间转换,时间的格式,结果的格式,例如:RobotFramework:日期格式转换问题
${date_to_search_for}= Convert Date 2017-06-14 13:03:02.506610 date_format=%Y-%m-%d 00:00:00.00000 result_format=%d %b %Y 00:00:00 exclude_millis=True
Log to console ${date_to_search_for}
运行这段代码,提出了这样的错误:
ValueError: time data '2017-06-14 13:03:02.506610' does not match format '%Y-%m-%d 00:00:00.00000'
我已经仔细检查这两种格式并看不出有什么不同!我不明白为什么它会抛出这个错误。
答
你给机器人日期:
2017-06-14 13:03:02.506610
是不是你说的是
date_format=%Y-%m-%d 00:00:00.00000
请使用日期时间的Python的格式化,像这样的格式:
${date_to_search_for}= Convert Date 2017-06-14 13:03:02.506610 date_format=%Y-%m-%d %H:%M:%S.%f result_format=%d %b %Y 00:00:00 exclude_millis=True
Log to console ${date_to_search_for}
请注意您的时间要求%H:%M:%S.%f
。
%H = 24 Hour Hour Time
%M = Minute with leading 0
%S = seconds with leading 0
%f = microseconds with leading 0
都可以找到Here
这将导致以下格式记录:
${date_to_search_for} = 14 Jun 2017 00:00:00
的任何问题请咨询:)
男人啊我们对此深感抱歉,金发天。在我的防守还没有咖啡。谢谢 – user3303266
没问题的伴侣,发生在我们身上! :D – Goralight
等待......仍然收到一个问题ValueError:时间数据'2017-06-14 13:03:02.506610'与格式不符'%Y-%m-%d 00:00:00.000000' – user3303266