PythonAnswer
2015-07-29 10:41:25 +08:00
In [1]:
# 字典实现
import re
from collections import OrderedDict
In [2]:
example = 'HAPPY: A,B,囧,5,6,7,d,e'
In [3]:
dict_values = re.sub(r'^.*\s*\:\s*', '', example).split(',')
In [4]:
dict_values
Out[4]:
['A', 'B', '囧', '5', '6', '7', 'd', 'e']
In [5]:
OrderedDict(zip(range(len(dict_values)), dict_values))
Out[5]:
OrderedDict([(0, 'A'), (1, 'B'), (2, '囧'), (3, '5'), (4, '6'), (5, '7'), (6, 'd'), (7, 'e')])