【发布时间】:2023-08-27 13:43:01
【问题描述】:
在 py_script.py 中:
import os
import sys
l = len(sys.argv)
if l == 1:
print 'no args'
else:
if l > 1:
print 'first arg is %s'%sys.argv[1]
if l > 2:
print 'second arg is %s'%sys.argv[2]
现在进入命令行,在我的 winXP 平台上:
d:\path\py_script.py 1 2
产量
first arg is 1
second arg is 2
但在我的 Win7 平台上,我得到了
no args
如果我这样做了
d:\path\python py_script.py 1 2
我明白了
first arg is 1
second arg is 2
如何让我的 Win7 环境按预期运行?
一些细节:
win7是64位的。
py2.6.6 on win7,py 2.6.4 on winXP。
【问题讨论】:
-
在 Win 7 和 2.7.1 上为我工作。
-
Windows 在 python 中解析 argv 真的很糟糕 :(
标签: python windows windows-7 command-line