How do I parse a string to a tuple??
kelvin.you at gmail.com
Mon Apr 30 12:10:33 CEST 2007
On Apr 30, 5:47 pm, Soren <soren.skou.niel... at gmail.com> wrote:
> I have a string that contains some text and newline characters. I want
> to parse the string so that the string just before a newline character
> goes in as an element in the tuple.
> "text1 \n text2 \n text3 \n text4" --> (text1, text2, text3, text4)
> Is there an easy way to do this?
tuple("text1 \n text2 \n text3 \n text4".split('\n'))
More information about the Python-list