Re: split a string of space separated substrings - elegant solution?
- From: Wojciech Muła <wojciech_mula@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 Jul 2007 20:57:46 +0000 (UTC)
Helmut Jarausch wrote:
Hi,
I'm looking for an elegant solution to the following (quite common)
problem:
Given a string of substrings separated by white space,
split this into tuple/list of elements.
The problem are quoted substrings like
abc "xy z" "1 2 3" "a \" x"
should be split into ('abc','xy z','1 2 3','a " x')
import csv
s = 'abc "xy z" "1 2 3" "a \\" x"'
r = iter(csv.reader([s], delimiter=" ", escapechar="\\"))
print r.next()
w.
.
- References:
- split a string of space separated substrings - elegant solution?
- From: Helmut Jarausch
- split a string of space separated substrings - elegant solution?
- Prev by Date: Re: Iteration over strings
- Next by Date: Python Package Index hostname change
- Previous by thread: split a string of space separated substrings - elegant solution?
- Next by thread: Re: split a string of space separated substrings - elegant solution?
- Index(es):
Relevant Pages
|