I have a list like this:
['',
'',
'']
From this I want to make sublists like:
id = ["32a45", "32a47", "32a48"]
date=["2017-01-01", "2017-01-05", "2017-01-07"]
How can I do that?
Thanks.
Edit: This was the original question
It is a broken xml file and tags are messed up, hence I cannot use xmltree. So I am trying something else.
解决方案
Simple solution using re.search() function:
import re
l = ['',
'',
'']
ids, dates = [], []
for i in l:
ids.append(re.search(r'id="([^"]+)"', i).group(1))
dates.append(re.search(r'date="([^"]+)"', i).group(1))
print(ids) # ['32a45', '32a47', '32a48']
print(dates) # ['2017-01-01', '2017-01-05', '2017-01-07']