Splitting string into dictionary

David Pratt fairwinds at eastlink.ca
Fri Jul 1 01:00:23 EDT 2005


I have string text with language text records that looks like this:

'en' | 'the brown cow' | 'fr' | 'la vache brun'

Two or more language records can exist in each string (example above 
shows 2 - but could contain more)
The second vertical line character in the example above is the record 
break in the pattern (between 'cow' and 'fr')

What is the shortest route to getting this into a dictionary like:

{'en':'the brown cow','fr':'la vache brun'}

The language code is always 2 lower case letters.

Many thanks.



More information about the Python-list mailing list