a question about the #prefix of sys.argv

Fossil Pan panyongzhi at gmail.com
Mon Jun 2 09:22:14 EDT 2008


On Jun 2, 8:50 am, Aldarion <ErendisAldar... at gmail.com> wrote:
> On 6月2日, 上午8时05分, Peter Otten <__pete... at web.de> wrote:
>
> > Aldarion wrote:
> > > for the little script
> > > #egg.py
> > > import sys
> > > for k,v in enumerate(sys.argv):
> > > print k,v
>
> > > it ignores  the part after # on linux
> > > below is the running output on windows and linux. no clue here.
>
> > This has nothing to do with python, it's the shell that treats the # and
> > everything that follows as a comment.
>
> > $ ./listargs.py alpha #beta
> > 0 ./listargs.py
> > 1 alpha
>
> > But you can escape it:
>
> > $ ./listargs.py alpha \#beta
> > 0 ./listargs.py
> > 1 alpha
> > 2 #beta
>
> > $ ./listargs.py alpha '#beta'
> > 0 ./listargs.py
> > 1 alpha
> > 2 #beta
>
> > Peter
>
> thanks everyone for the quickly reply, i see now.

Thank you Aldarion for your post.



More information about the Python-list mailing list