0 votes
1 view
in Python by (47.8k points)

I have a string which is like this:

this is "a test"

I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:

['this','is','a test']

1 Answer

0 votes
by (107k points)

You want split, from the shlex module.

>>> import shlex 

>>> shlex.split('this is "a test"') 

['this', 'is', 'a test']

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 3, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...