Splitting a line while keeping quoted items together

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Nov 19 20:09:54 EST 2012


On Mon, 19 Nov 2012 16:05:30 -0800, josh wrote:

> I am working on a cmd.Cmd-based program, and normally could just split
> the string and get the right parts.
> 
> Now I have a case where I could have two or three words in the string
> that need to be grouped into the same thing.

Try shlex.split.



-- 
Steven



More information about the Python-list mailing list