What is “argv”, and what does it do?

前端 未结 7 1660
耶瑟儿~
耶瑟儿~ 2020-11-30 04:36

argv

What on Earth is it!?

Edit: If you can, will you please write a line or two and explain how it works?

相关标签:
7条回答
  • 2020-11-30 05:10

    Script printArgv.py:

    import sys
    print sys.argv.__class__
    spam = sys.argv[1:]
    print spam
    

    Run it with: python printArgv.py 1 2 3 4 5

    You would find the output:

    <type 'list'>
    ['1', '2', '3', '4', '5']
    

    Which means the sys.argv is a list of parameters you input following the script name.

    0 讨论(0)
提交回复
热议问题