A. Archer A. Archer - 3 months ago 15
Python Question

split list by delimited in python

From a dict/list, how to split the list by \n. Eg:

In [1]: d = {'key1': 'value1\n value2 \n value3\n'}

In [2]: d.values()
Out[2]: ['value1\n value2 \n value3\n']


Desired output:

['value1', 'value2 ', 'value3']


I looked at existing examples but couldn't find this specific one.

Answer

Here you go:

d['key1'].split('\n')