Get the complete command line as-is
zzbbaadd at aol.com
Wed Sep 12 07:00:29 CEST 2007
On Sep 11, 8:33 pm, TheFlyingDutchman <zzbba... at aol.com> wrote:
> On Sep 11, 8:00 pm, wangzq <wan... at gmail.com> wrote:
> > Hello,
> > I'm passing command line parameters to my browser, I need to pass the
> > complete command line as-is, for example:
> > test.py "abc def" xyz
> > If I use ' '.join(sys.argv[1:]), then the double quotes around "abc
> > def" is gone, but I need to pass the complete command line ("abc def"
> > xyz) to the browser, how can I do this?
> > I'm on Windows.
> > Thanks.
> I'm on Solaris and this works for me:
> test.py '"abc def" xyz'
> print sys.arv
> "abc def" xyz
OK, now I'm on Windows XP and things aren't looking too good.
It seems that \" will retain the quote marks but then the spaces get
But if you replace the spaces with another character:
python.exe test.py \"abc#def\"#123
commandLine = "".join(sys.argv[1:])
prints commandLine.replace('#',' ')
"abc def" 123
Don't know if you can use that technique or not.
More information about the Python-list