我有我应该忽略日期字符串中的时间戳的情况。我已经尝试了下面的命令,但没有运气。从Python中的日期字符串中删除时间戳
"start" variable used below is in AbsTime (Ex: 01MAY2017 11:45) and not a string.
start_date = datetime.datetime.strptime(start, '%d%^b%Y').date()
print start_date
我的输出应该是:
01MAY2017 or 01MAY2017 00:00
可以在任何一个可以帮助我。
'start.split() [0]'会给你第一个输出 –
好奇:你从哪里得到'%^ b'的想法? –
@MartijnPieters可能是一个错字。 '%'&'^'在常规键盘上的“5”和“6”(换档)上。 –