sys.argv[1] meaning in script

后端 未结 9 1397
野趣味
野趣味 2020-11-22 11:02

I\'m currently teaching myself Python and was just wondering (In reference to my example below) in simplified terms what the sys.argv[1] represents. Is it simpl

9条回答
  •  抹茶落季
    2020-11-22 11:41

    sys.argv is a list.

    This list is created by your command line, it's a list of your command line arguments.

    For example:

    in your command line you input something like this,

    python3.2 file.py something
    

    sys.argv will become a list ['file.py', 'something']

    In this case sys.argv[1] = 'something'

提交回复
热议问题