RobotFramework:日期格式转换问题

use*_*266 1 date-format 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}
Run Code Online (Sandbox Code Playgroud)

运行此代码,出现此错误:

ValueError: time data '2017-06-14 13:03:02.506610' does not match format '%Y-%m-%d 00:00:00.00000'
Run Code Online (Sandbox Code Playgroud)

我仔细检查了两种格式,看不出有什么不同!我不明白为什么它会抛出这个错误。

Gor*_*ght 5

您给机器人的日期:

2017-06-14 13:03:02.506610
Run Code Online (Sandbox Code Playgroud)

不是你说的格式

date_format=%Y-%m-%d 00:00:00.00000
Run Code Online (Sandbox Code Playgroud)

请像这样使用 DateTime 的 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}
Run Code Online (Sandbox Code Playgroud)

请注意%H:%M:%S.%f您的时间要求。

%H = 24 Hour Hour Time
%M = Minute with leading 0
%S = seconds with leading 0
%f = microseconds with leading 0
Run Code Online (Sandbox Code Playgroud)

都可以找到 这里

这将导致记录以下格式:

${date_to_search_for} = 14 Jun 2017 00:00:00
Run Code Online (Sandbox Code Playgroud)

有什么问题请追问:)