在Windows控制台中,如果执行此脚本(test.py
):
import sys
print(sys.argv)
比如:
>python test.py my args
我得到了预期的结果:
['test.py', 'my', 'args']
但如果我直接这么说:
>test.py my args
我得到:['C:\\temp\\test.py']
输出,好像我没有传递任何参数。为什么
仅供参考:
>assoc | findstr .py=
.py=Python.File
>ftype Python.File
Python.File=C:\Python35\python.exe "%1" %*
与讨论here类似,您需要确保
command
键设置正确。在我的windows10副本上,我发现有两个地方的command
reg设置为"C:\Python27\python.exe" "%1" %*
我想首先要检查这两把钥匙
相关问题 更多 >
编程相关推荐