首页 > 解决方案 > 如何在 DatetTime Library Robotframework 中将日期转换为从 Month 中丢失前导零?

问题描述

我有以下代码

${d}=    Get Current Date    result_format=%m/%d/%Y
log  ${d}

输出是

2018 年 6 月 14 日

在我的期望中,我想要

2018 年 6 月 14 日

谢谢

标签: robotframework

解决方案


你能试一下吗

${d}=    Get Current Date    result_format=%#m/%d/%Y
log  ${d}

在月份前面使用“#”来消除零。参考链接

请注意,这取决于平台;对于 Unix (Linux/MacOS),您需要使用连字符:

%Y/%-m/%-d


推荐阅读