I have a string like this
PARAMS = 'TEST = xy; TEST2= klklk '
which I want to split twice, once at the ";" and second on the "=" and then put it in a dict.
I can do it with this line:
dict(item.split("=") for item in PARAMS.split(";"))
and get:
{' TEST2': ' klklk ', 'TEST ': ' xy'}
I would now also like to strip the key and value before putting them in the dict. Is there an elegant way to do it in one line in python?
This runs a lot faster than @aIKid's solution :)
Output