import shlex temp = "abc 'afasfasfs aaaa' dgg" print(shlex.split(temp) > ['abc', 'afasfasfs aaaa', 'dgg']