请问一下sys模块的有关问题
请教一下sys模块的问题#!/usr/bin/python# Filename: using_sys.pyimport sysprint The command line arg
请教一下sys模块的问题
#!/usr/bin/python
# Filename: using_sys.py
import sys
print 'The command line arguments are:'
for i in sys.argv:
print i
print '\n\nThe PYTHONPATH is', sys.path, '\n'
输出
$ python using_sys.py we are arguments
The command line arguments are:
using_sys.py
we
are
arguments
The PYTHONPATH is ['/home/swaroop/byte/code', '/usr/lib/python23.zip',
'/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2',
'/usr/lib/python2.3/lib-tk', '/usr/lib/python2.3/lib-dynload',
'/usr/lib/python2.3/site-packages', '/usr/lib/python2.3/site-packages/gtk-2.0']
可是我输出的
The command line arguments are:
C:\Python23\using_sys.py
The PYTHONPATH is ['C:\\Python23\\Lib\\idlelib', 'C:\\Python23\\python23.zip', 'C:\\Python23', 'C:\\Python23\\DLLs', 'C:\\Python23\\lib', 'C:\\Python23\\lib\\plat-win', 'C:\\Python23\\lib\\lib-tk', 'C:\\Python23\\lib\\site-packages']
我的输出和例子的输出不一样。后来我发现,只要是关于sys模块的例子,我的输出都和例子的输出不一样,求解
[解决办法]参数是你在命令行下执行这个文件的时候自己敲的,你不输入参数,参数何来?