python: sys.argv[0] meaning in official documentation

前端 未结 3 1966
醉话见心
醉话见心 2020-12-19 12:21

Quoting from docs.python.org:

\"sys.argv The list of command line arguments passed to a Python script. argv[0] is the script name (it is op

3条回答
  •  春和景丽
    2020-12-19 12:54

    When Python is invoked as python script.py then sys.argv[0] == 'script.py'. When you invoke python -c 'import sys; print sys.argv' then sys.argv[0] == '-c' indicating the script body was passed as a string on the command line.

提交回复
热议问题