Shi*_*ade 0 python attributes runtime-error argv command-line-arguments
我访问命令行参数的代码:
length = len(sys.argv)
print length
str = sys.arvg[0]
print str
Run Code Online (Sandbox Code Playgroud)
给出输出:
triongle@triongle.com [~/download/DataInsertionScript]# python IngestDataToMongo.py python_sucks
2
Traceback (most recent call last):
File "IngestDataToMongo.py", line 83, in <module>
str = sys.arvg[0]
AttributeError: 'module' object has no attribute 'arvg'
Run Code Online (Sandbox Code Playgroud)
所以,第一次len(sys.argv)工作,但奇怪的是下次在sys.argv [0]上给出错误.那为什么呢?