2

I'm using python 3.3.0 in windows 8.

This is the code which I'm trying to deal with:-

import sys

for arg in sys.argv:
    if arg == "-u":
        url = sys.argv[2]
        print (url)
        sys.exit(1)

So, When I run my program in cmd like:

python my.py -u http://www.aytelecom.ae/news-details.php?id=5&type=2

I'm getting only 'http://www.aytelecom.ae/news-details.php?id=5' as my sys.argv[2] or in url variable!

So, can anybody tell me that why it's skipping '&type=2'? Am I doing mistake anywhere or what's wrong with python 3?

4

1 に答える 1

6

&はシェルのメタ文字です。URLを引用符で囲みます。

于 2012-10-24T12:53:02.913 に答える