利用sys这个模块来进行操作,
[html]
view plain
copy
- #!/usr/bin/python
- #filename:using_sys.py
- import sys
- print 'the command line arguments are:'
- for i in sys.argv:
- print i
- print '\n\n The PYTHONPATH is\n',sys.path,'\n'
[html]
view plain
copy
- [root@fsailing1 python]# python using_sys.py we are studying python
- the command line arguments are:
- using_sys.py
- we
- are
- studying
- python
- The PYTHONPATH is
- ['/root/python', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/gtk-2.0']