本文介绍了根据Python中的日期解析字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串:
我需要将此字符串解析成片段,以便每个片段以日期开始。为此,我试图从正则表达式中受益:
I need to parse this string into pieces so that each piece starts with dates. For this purpose, I tried to benefit from regex like :
match = re.search(r'\d{2}-\d{2}-\d{4}', text)
但是这个代码只找到日期。我不能进一步我需要有一些片段:
But this code only finds dates. And I cant go further. I need to have pieces such as:
second_piece:19-11-2014 11:17 - KH - (KH)Igangværende - Opringning - 13-11 00:00 Gikpåsvarer igen og lagt besked til RLI在铃兰
second_piece: 19-11-2014 11:17 - KH - (KH) Igangværende - Opringning - 13-11 00:00 Gik på svarer igen og lagt besked til RLI at ringe tilbage.
等等。
请你给我一些关于实现这些子串?
Could you please give me some insights about achieving these sub strings?
提前感谢
推荐答案
p>
Does this work?
re.split(r' (?=\d{2}-\d{2}-\d{4})', text)
这篇关于根据Python中的日期解析字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!