[英]sys.argv is not taking provided argument in python 3
I'm using python 3.3.0 in windows 8. 我在Windows 8中使用python 3.3.0。
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: 因此,当我在cmd中运行程序时,如下所示:
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! 我的sys.argv[2]
或url
变量中只有'http://www.aytelecom.ae/news-details.php?id=5
'!
So, can anybody tell me that why it's skipping '&type=2'
? 因此,有人可以告诉我为什么它跳过'&type=2'
吗? Am I doing mistake anywhere or what's wrong with python 3? 我在任何地方都犯错了,或者python 3出了什么问题?
& is a metacharacter in shell. &是外壳程序中的元字符。 Put the url in quotes. 将该网址放在引号中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.