sys.argv[1] meaning in script

后端 未结 9 1483
野趣味
野趣味 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:52

    To pass arguments to your python script while running a script via command line

    python create_thumbnail.py test1.jpg test2.jpg

    here, script name - create_thumbnail.py, argument 1 - test1.jpg, argument 2 - test2.jpg

    With in the create_thumbnail.py script i use

    sys.argv[1:]
    

    which give me the list of arguments i passed in command line as ['test1.jpg', 'test2.jpg']

提交回复
热议问题